#43017·PrestaShop

[Extra Properties] Module::registerExtraProperty() throws instead of returning false on an invalid label or description domain

Author: mattgoudCreated Sep 28, 2026Updated Sep 28, 2026

Prerequisites

  • I understand and accept the project's code of conduct.
  • I have already searched in existing issues and found no previous report of this bug.

Describe the bug and add attachments

Module::registerExtraProperty() and Module::unregisterExtraProperty() are documented to return false on any failure and to put the reason in the module errors ("so install code can simply test the returned value like it does for every other register* method").

They can throw instead. Both inject the module name with $definition->withModuleName($this->name) before their try block (classes/module/Module.php:1255 vs :1261 on 9.2.x, same shape in unregisterExtraProperty()). withModuleName() rebuilds the value object, and its constructor only runs the "label/description domain must belong to the module" check once a module name is set (ExtraPropertyDefinition.php:465). So a definition built without moduleName, which is the documented pattern, with a domain of another module passes construction, then throws InvalidExtraPropertyDefinitionException from inside registerExtraProperty().

InvalidExtraPropertyDefinitionException extends ExtraPropertyException, which the existing catch already handles. Moving the injection inside the try in both methods is enough.

Found while reviewing the Extra Properties documentation (PrestaShop/docs#2169).

Steps to reproduce

  1. Install the demoextraproperty example module (PrestaShop/example-modules).
  2. Run, from a script booting the admin kernel:
    php
    $module = Module::getInstanceByName('demoextraproperty');
    $definition = new ExtraPropertyDefinition(
        entityName: 'product',
        propertyName: 'qa_dom',
        labelWording: 'X',
        labelDomain: 'Modules.Othermodule.Admin',
    );
    $module->registerExtraProperty($definition);
    $module->unregisterExtraProperty($definition, true);

Expected behavior

Both calls return false, and $module->getErrors() contains the reason.

Actual Result

Both calls throw PrestaShop\PrestaShop\Core\ExtraProperty\Exception\InvalidExtraPropertyDefinitionException:

ExtraPropertyDefinition: labelDomain "Modules.Othermodule.Admin" of a module-owned definition must belong to the module ("Modules.Demoextraproperty.…") (entity "product", property "qa_dom", module "demoextraproperty").

A module whose install() follows the documented if (!$this->registerExtraProperty(...)) return false; pattern gets an uncaught exception instead.

PrestaShop version where the bug happens

9.2.x (d4da8a1d85a)

How have you installed PrestaShop

From the GitHub repository (docker dev env)

PHP version(s) where the bug happened

8.1

Your company or customer's name goes here (if applicable).

PrestaShop SA