Skip to content

fix(schema): use FQCN for core model classes to resolve PSR-4 deprecation#16919

Open
Ibochkarev wants to merge 4 commits intomodxcms:3.xfrom
Ibochkarev:fix/schema-fqcn-psr4-deprecation
Open

fix(schema): use FQCN for core model classes to resolve PSR-4 deprecation#16919
Ibochkarev wants to merge 4 commits intomodxcms:3.xfrom
Ibochkarev:fix/schema-fqcn-psr4-deprecation

Conversation

@Ibochkarev
Copy link
Copy Markdown
Collaborator

@Ibochkarev Ibochkarev commented Mar 8, 2026

What does it do?

Use fully qualified class names (FQCN) for all core model classes in core/model/schema/modx.mysql.schema.xml. Replaces every short class name (e.g. class="modNamespace", class="modResource", class="modUser") with MODX\\Revolution\\* equivalents. Covers modNamespace, modPlugin, modPluginEvent, modSystemSetting, modMenu, modResource, modUser, modTemplate, modChunk, modSnippet, modCategory, modContext, modEvent, modFormCustomization*, modTemplateVar*, modUserGroup*, modAccess*, and all other mod* objects in the main schema.

Additionally, modX::loadClass() now normalizes short mod* names to FQCN at runtime. When legacy code or xPDO call paths pass short names (e.g. modResource, modAccessContext), they are converted to MODX\Revolution\* internally. A class_alias is created for backward compatibility. This avoids deprecation notices from getObject, getCollection, newQuery, and other paths that invoke loadClass before modAccessibleObject::load.

Why is it needed?

Short names in the schema cause the profiler and modX::loadClass() to trigger v3.0 deprecation warnings that tell users to replace references with MODX\\Revolution\\* for PSR-4 autoloading. Application code already uses modNamespace::class and equivalent; the warnings come from the schema-defined class attribute and the resulting xPDO map keys. Updating the schema to FQCN aligns metadata with PSR-4 and removes the deprecation notices. Runtime normalization in loadClass() handles remaining call paths that still pass short names.

How to test

Run the application with the profiler or deprecation log enabled; verify that deprecation warnings for mod* classes from this schema no longer appear. Optionally rebuild the model from the updated schema and confirm the map uses FQCN.

Related issue(s)/PR(s)

None.

Replace class="modNamespace" with class="MODX\Revolution\modNamespace"
in modx.mysql.schema.xml so the profiler and loadClass no longer trigger
the v3.0 deprecation warning for short class name.
Replace short class names with MODX\Revolution\ FQCN in modx.mysql.schema.xml
to resolve PSR-4 deprecation warnings in profiler (v3.0).
Replace short class names with MODX\Revolution\* for modAccess, modMenu,
modResource, modUser, modTemplate, modChunk, modSnippet, modCategory,
modContext, modEvent, modFormCustomization*, modTemplateVar*, modUserGroup*,
and all other core model classes in modx.mysql.schema.xml to resolve
PSR-4 deprecation warnings (v3.0).
…ility

Add isShortModClassName() helper and runtime normalization in loadClass().
Short names (modResource, modAccessContext, etc.) are converted to
MODX\Revolution\* FQCN to avoid deprecation from xPDO call paths.
Creates class_alias for backward compatibility.
@Ibochkarev Ibochkarev marked this pull request as ready for review March 8, 2026 17:24
@Mark-H
Copy link
Copy Markdown
Collaborator

Mark-H commented Mar 18, 2026

I'm confused about the schema changes - all objects are already in the \MODX\Revolution package so this is already getting prepended as namespace when the model is built. It seems like this would cause that it to get doubled up.

Any deprecation warnings should come from specific usages using the short name, not the core schema. But as there's no issue linked or deprecation warning shown, it's unclear what specifically we're fixing.

The loadClass fix I could get behind but would want to test with third-party extras that have (perhaps unwisely so) used the mod prefix in their models.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants