Skip to content

Fix DocumentDataManagerController not found for legacy class_key - #17008

Open
Ibochkarev wants to merge 1 commit into
modxcms:3.xfrom
Ibochkarev:fix/issue-15080-document-data-controller
Open

Fix DocumentDataManagerController not found for legacy class_key#17008
Ibochkarev wants to merge 1 commit into
modxcms:3.xfrom
Ibochkarev:fix/issue-15080-document-data-controller

Conversation

@Ibochkarev

Copy link
Copy Markdown
Collaborator

What changed and why

Resource Overview (resource/data) threw Class 'DocumentDataManagerController' not found when a resource stored the legacy short class_key modDocument (common for API/extra creates) or when class_key was present in the request.

ResourceManagerController::getInstance() treated those keys as derivatives and rewrote the controller name via getAlias(), but unlike create/update (#15997) the data controller had no DocumentDataManagerController alias. Short keys also failed STI lookup when overview loaded via modDocument::class.

This change:

  • Treats short and FQCN core document keys as non-derivative in getInstance()
  • Adds DocumentDataManagerController alias (parity with create/update)
  • Loads overview through modResource::class so short keys still resolve
  • Keeps the existing rewrite of improper modResource / modResource short keys only (does not rewrite short modDocument on GET)

How to test

  1. Create a resource with class_key = modDocument (short), open Manager → Overview for that resource. Expect no class-not-found error.
  2. Open ?a=resource/data&id=1&class_key=MODX\Revolution\modDocument (and with short modDocument). Expect the overview controller to load.
  3. Overview a Weblink. Expect WebLinkDataManagerController still.
  4. Gate E:
    • php -l manager/controllers/default/resource/resource.class.php → exit 0
    • php -l manager/controllers/default/resource/data.class.php → exit 0
    • core/vendor/bin/phpunit -c _build/test/phpunit.xml --filter ResourceManagerControllerGetInstanceTest --no-coverage → OK (9 tests, 27 assertions)
    • core/vendor/bin/phpcs --standard=phpcs.xml _build/test/Tests/Controllers/Resources/ResourceManagerControllerGetInstanceTest.php → exit 0

Related issue(s)/PR(s)

Resolves #15080

Related: #16004 / #15997 (DocumentCreate/DocumentUpdate aliases). Collections short class_key context: modxcms/Collections#353.

Compatibility notes

Universal. Helps installs/extras that still persist short modDocument. Does not migrate existing short modDocument rows on overview GET.

Breaking change assessment

No public API signature changes. Create with a core-document class_key request param now skips the derivative controller rename path and instantiates ResourceCreateManagerController directly (equivalent to the previous alias path).

Test coverage

Added _build/test/Tests/Controllers/Resources/ResourceManagerControllerGetInstanceTest.php for short/FQCN document keys, Weblink derivative regression, and the DocumentData alias.

Contributors

Thanks @Ruslan-Aleev for the original report and @Lystapad for identifying the short class_key path.

AI tool use

Cursor agent assisted with investigation, implementation, tests, and PR drafting under human direction.

Treat short modDocument/modResource as core documents in getInstance, add the DocumentData alias (parity with create/update), and load overview via modResource so STI still resolves short keys.
@Ibochkarev Ibochkarev added the bug The issue in the code or project, which should be addressed. label Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug The issue in the code or project, which should be addressed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When viewing a resource, an error is returned - Class 'DocumentDataManagerController' not found

1 participant