* FIX: Restore PHPUnit 11 compatibility in CommonClassTest
onNotSuccessfulTest() overrode PHPUnit\Framework\TestCase's method with
an incompatible return type (void vs never), and the assertMatchesRegularExpression
back-compat shim for PHPUnit <8 now illegally overrides that method, which
PHPUnit 11 declares final. Both faults made every test extending
CommonClassTest fatal immediately on this environment's PHPUnit 11.5.55.
Pre-existing breakage, unrelated to the PDF mutualization work in this
branch — fixed here because Task 1's plan requires a passing
BuildDocTest.php baseline before any implementer is dispatched.
* NEW: Mutualize PDF header logo block into pdf_writeLogoOrCompanyName() (sponge, einstein, azur, muscadet)
* NEW: Mutualize PDF header logo block into pdf_writeLogoOrCompanyName() (cornas, standard, cyan, octopus, strato)
* FIX: Resolve $logodir before calling pdf_writeLogoOrCompanyName() in cornas, standard, cyan, octopus, strato
* NEW: Mutualize PDF header logo block into pdf_writeLogoOrCompanyName() (eratosthene, eagle_proforma, standard_asset)
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* NEW: Mutualize PDF header logo block into pdf_writeLogoOrCompanyName() (aurore, zenith)
* FIX: Complete PHPUnit 11 compatibility fix in CommonClassTest::onNotSuccessfulTest
The prior compatibility fix (f29129aae43) resolved the two class-load
fatals but left onNotSuccessfulTest() calling getName()/getDataSetAsString(),
neither of which exists on PHPUnit 11's TestCase (renamed to name() and
dataSetAsStringWithData()/dataSetAsString()). The undefined-method error
was silently absorbed by PHPUnit's own exception handling, so every test
failure across the suite still ran and reported correctly, but the
method's entire diagnostic block (log tail, backtrace, DB info dump) never
executed. Verified with a throwaway reproduction test before and after:
the diagnostic ##[group] output was empty before this fix and complete
after it.
Found during the final whole-branch review of the PDF logo-block
mutualization branch; unrelated to that refactor but touches the same
file already modified by the earlier compatibility commit.
* FIX: Drop unneeded by-ref $pdf and rename $ltrdirection to $align in pdf_writeLogoOrCompanyName()
TCPDF objects are handles, so passing $pdf by reference bought nothing
and was inconsistent with every sibling function in this file
(pdf_pagehead, pdf_watermark, pdf_bank, pdf_pagefoot, ...), all of which
take $pdf by value. $ltrdirection was also a misnomer: three of the 14
callers pass the literal 'L' and one passes 'J' (justify) - none of those
is a text direction, it's an alignment. Renaming is call-site-transparent
(all 14 callers use positional arguments).
Found during the final whole-branch review of the PDF logo-block
mutualization branch.
* NEW: Document pdf_writeLogoOrCompanyName() helper in ChangeLog
Per repo convention (CLAUDE.md: "Always update ChangeLog for
significant changes"). Flagged during the final whole-branch review
of the PDF logo-block mutualization branch: a new reusable pdf_lib.php
function is part of the surface third-party PDF document-model modules
build against.
* restore commonclasstest
* fix
---------
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
The addproperty action built the field definition array without capturing
propshowoncombobox, so the 'Show on combobox' option chosen in the property
form was silently dropped for every field; only ref and code got it (they
are hardcoded in the build-from-table path). Capture it like the other
field flags so rebuildObjectClass serializes it into the generated class.
Fixes#35076.
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
The generated list page set $trackid = 'xxxx'.$object->id, where 'xxxx'
is not a NamingContract substitution token. It leaked verbatim into every
generated module and made the mass-emailing trackid collide across modules.
Align it with the card page (myobject_card.php) and core list pages
(comm/propal/list.php => 'pro', societe/list.php => 'thi') by using the
substitutable 'myobject' token, so the trackid derives from the object name.
Addresses #32460 (item 14, email/trackid handling).
Next: push to remote quentin, open upstream PR on Dolibarr/dolibarr:develop
Next: linking #32460 item 14
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
* NEW : add ModuleBuilder object-tabs map and filter helpers
Add getModuleBuilderObjectTabs() (source-of-truth map of optional object
tabs) and filterEnabledTabs() (sanitizes user-requested tab keys against the
map). Covered by ModuleBuilderLibTest.
Next: add BEGIN/END markers around tab flags and blocks in template lib (Task 2)
* NEW : wrap object tab flags and blocks with MODULEBUILDER markers
Surround each optional tab flag declaration (TABFLAG) and each prepareHead tab
block (TAB) with BEGIN/END MODULEBUILDER comment markers, so the generator can
purge a whole tab atomically while keeping $h and $head intact. Card tab is
not wrapped (always generated).
Next: add tab selection checkboxes to the newobject form in modulebuilder/index.php (Task 3)
* NEW : add object tab selection checkboxes to newobject form
Render one checkbox per optional tab (contact, note, document, agenda) in the
ModuleBuilder newobject form, all checked by default and reflecting posted
state on redisplay.
Next: handle enabledtab in initobject — exclude files, purge blocks, hardcode flags (Task 4)
* NEW : apply object tab selection during object generation
Excludes page files of unselected tabs, purges their prepareHead flag and
block via MODULEBUILDER markers, and hardcodes the show flag to 1 for selected
tabs. Emits a best-effort warning when regenerating an existing object.
Next: add language keys EnabledTabsForObject(Help) + WarningTabSelectionOnRegeneration (Task 5)
* NEW : add language keys for object tab selection
Next: add ChangeLog entry (Task 6)
* DOC : changelog entry for ModuleBuilder selectable object tabs
* FIX : purge agenda card widget when agenda tab is excluded
Audit finding: myobject_card.php hardcodes a 'SeeAll' link to myobject_agenda.php
in an event widget. When the agenda tab is excluded the page is not generated,
leaving a latent dead link if the widget is enabled. Wrap the widget with
MODULEBUILDER TAB AGENDA markers and purge it from the generated card when the
agenda tab is not selected.
Next: functional verification (step 5 of dev workflow)
* FIX : check file operation results when applying object tab selection
PR review: align with the nogeneratelines pattern by checking the return of
removePatternFromFile/dolReplaceInFile and raising $error + dol_syslog with the
failing tab/file context, instead of ignoring silent write failures during
object generation. Add PR reference to the changelog entry.
* FIX : do not abort object generation when nogeneratelines targets a missing file
The nogeneratelines handler purges the MODULEBUILDER LINES block from class,
API and card files. When API generation is disabled the api_<module>.class.php
file does not exist, so removePatternFromFile returns false and $error was
incremented, which skipped the whole success path (name substitution,
rebuildObjectClass, $tabobj assignment). Generated classes kept the literal
'class MyObject', so dolGetListOfObjectClasses listed every object as MyObject.
Guard each purge with file_exists so a missing optional file is skipped.
* FIX : keep module descriptor out of the blanket name substitution
The 'substitute all module php files' pass applied the object/module name map
to every .php file including the module descriptor. That rewrote the persistent
/* ... MODULEBUILDER TOPMENU/LEFTMENU MYOBJECT */ marker placeholders to the
first object name, so generating a second object could no longer find them
(checkExistComment returned -1, 'comments not found for section Menus' warning)
and its menu entries were not inserted. Skip the descriptor in that loop: its
module name is already resolved by initmodule and its object entries are added
by the dedicated menu/permission blocks.
* FIX : preserve MODULEBUILDER markers when substituting the module descriptor
The previous commit only skipped the descriptor in the secondary substitution
pass, but the primary pass (over $filetogenerate, which includes the descriptor)
still rewrote its persistent /* ... MODULEBUILDER TOPMENU/LEFTMENU MYOBJECT */
markers to the first object name. Those markers cannot simply be excluded from
substitution because the descriptor also has functional MYOBJECT/MYMODULE tokens
(e.g. the MYMODULE_MYOBJECT_ADDON numbering constant) that must be resolved.
Add dolReplaceInFilePreservingModuleBuilderMarkers(): it hides every MODULEBUILDER
marker behind a sentinel, applies the substitution, then restores the markers
verbatim. Use it for the descriptor in the primary pass; the descriptor stays
excluded from the secondary pass. Generating a second object now finds the
markers (checkExistComment) and inserts its menu entries without warning.
Verified by CLI: markers preserved across two successive objects, while content
(rights, exports, addon constant) is correctly substituted.
* FIX : silence phan on the new ModuleBuilder test and typed closure
CI phan (diff-only) flagged the freshly added test file: PhanUndeclaredExtendedClass
(\CommonClassTest) and PhanUndeclaredMethod (assertSame), like the sibling
NamingContractTest. Add the same @phan-file-suppress block (plus
PhanTypeMismatchArgumentProbablyReal for the non-array guard test case). Also
type the preg_replace_callback parameter (array $matches) to clear
PhanPluginUnknownClosureParamType. phpstan is already green; no phpstan
annotations added.
* FIX : drop closure in marker-preserving substitution to satisfy phan
phan's PhanPluginUnknownArrayClosureParamType wanted key/value types on the
preg_replace_callback closure parameter. Replace the callback with preg_match_all
plus a str_replace loop over the unique markers: same behaviour, no closure,
no plugin warning.
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>