Skip to content

composer autoload-dev (OCA\OpenRegister\ → tests/Stubs/) shadows the real OpenRegister classes in production #230

Description

@rubenvdlinde

composer.json declares

"autoload-dev": { "psr-4": { "OCA\\OpenRegister\\": "tests/Stubs/" } }

and tests/Stubs/Db/ObjectEntity.php is an abstract stub. When SoftwareCatalog's vendor/ is built with a plain composer install (i.e. with dev deps — which is what gets deployed to the dev container / Nextcloud apps dir), the dev autoloader is active, so its vendor/composer/autoload_psr4.php / autoload_classmap.php map OCA\OpenRegister\Db\ObjectEntitytests/Stubs/Db/ObjectEntity.php. Because every enabled app's vendor/autoload.php is registered globally, that mapping then shadows the real OCA\OpenRegister\Db\ObjectEntity for all apps — so OpenRegister's own MagicSearchHandler::convertRowToObjectEntity() does new ObjectEntity() and PHP fatals with Cannot instantiate abstract class OCA\OpenRegister\Db\ObjectEntity. This takes down OpenRegister's entire object-read path (and therefore every OR-backed app) on a dev install that has SoftwareCatalog enabled. Disabling SoftwareCatalog (so its autoloader is no longer registered) restores OR.

Fixes (any of):

  • Deploy SoftwareCatalog with composer install --no-dev so the dev autoloader isn't loaded in production.
  • Don't PSR-4-map a foreign namespace (OCA\OpenRegister\) at all — load the stubs only from the PHPUnit bootstrap (tests/bootstrap.php require), not via composer autoload.
  • Namespace the stubs under OCA\SoftwareCatalog\Tests\Stubs\… and class_alias() them to OCA\OpenRegister\… only inside the test bootstrap.

(Surfaced while resetting the OpenRegister dev environment — clean-env.sh + re-enabling all ConductionNL apps left OR's object layer crashing until SoftwareCatalog was disabled.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions