diff --git a/ChangeLog b/ChangeLog index d8ea24a760a..feae4d11308 100644 --- a/ChangeLog +++ b/ChangeLog @@ -177,6 +177,7 @@ For developers: NEW: Use another hash algorithm v2 based on sha256/hmac for immutable logs (#37725) NEW: Replace MyObject MyModule occurrences (#38370) NEW: ModuleBuilder - Allow selecting which optional tabs (contact, note, document, agenda) are generated for an object (#38570) +FIX: ModuleBuilder - Generated list page derives the email trackid from the object name instead of the leftover 'xxxx' placeholder (#32460) NEW: add hooks in reception card (#37214) NEW: add new hook in BonPrelevement::EnregDestinataireSEPA() function (#37419) NEW: Add hook selectForFormsListUrl in Form::selectForForms (#37447) diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 834fe289a4c..7d8bad82a3a 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -603,7 +603,7 @@ print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sort $topicmail = "SendMyObjectRef"; $modelmail = "myobject"; $objecttmp = new MyObject($db); -$trackid = 'xxxx'.$object->id; +$trackid = 'myobject'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($search_all) { diff --git a/test/phpunit/NamingContractTest.php b/test/phpunit/NamingContractTest.php index 1824d3c2e00..773b62d4c5c 100644 --- a/test/phpunit/NamingContractTest.php +++ b/test/phpunit/NamingContractTest.php @@ -154,6 +154,32 @@ class NamingContractTest extends \PHPUnit\Framework\TestCase $this->assertSame($content, $nc->applyTo($content)); // @phpstan-ignore method.notFound } + // ── Generated list template — trackid placeholder (#32460 item 14) ──── + + /** + * The generated list page must derive its e-mail trackid from the object name, + * exactly like the card page (myobject_card.php) and core list pages + * (comm/propal/list.php => 'pro', societe/list.php => 'thi'). The legacy literal + * 'xxxx' placeholder is not a substitution token, so it used to leak verbatim into + * every generated module and collide across modules in the mass e-mailing trackid. + * Regression guard for #32460 (item 14, e-mail/trackid handling). + * + * @return void + */ + public function testListTemplateTrackidIsSubstituted(): void + { + $template = file_get_contents(dirname(__FILE__) . '/../../htdocs/modulebuilder/template/myobject_list.php'); + $this->assertIsString($template); // @phpstan-ignore method.notFound + + // The non-substitutable 'xxxx' placeholder must no longer carry the trackid. + $this->assertStringNotContainsString("\$trackid = 'xxxx'", $template, "The list template must not carry the 'xxxx' trackid placeholder"); // @phpstan-ignore method.notFound + + // After generation the trackid derives from the object name, like the card page and core. + $nc = new NamingContract('invoice', 'request'); + $result = $nc->applyTo($template); + $this->assertStringContainsString("\$trackid = 'request'.\$object->id;", $result, 'Generated trackid must derive from the object name'); // @phpstan-ignore method.notFound + } + // ── NamingContract — applyToFilename ───────────────────────────────── /**