fix(schema): use FQCN for core model classes to resolve PSR-4 deprecation#16919
fix(schema): use FQCN for core model classes to resolve PSR-4 deprecation#16919Ibochkarev wants to merge 5 commits into
Conversation
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.
|
I'm confused about the schema changes - all 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 |
|
On the |
|
@Ibochkarev - Hey, just wanted to get your response to Mark's and my comments above and whether you want to continue to pursue this change. Thx ;-) |
Revert schema FQCN and loadClass normalization based on review feedback. The schema package already prepends MODX\Revolution\, and silencing deprecation in loadClass() undermines the v3.0 migration path. Fix remaining core call sites that still passed short names to getObject() and loadAttributes().
|
Thanks @Mark-H and @smg6511 — really helpful feedback, and sorry for the slow reply. After re-reading your comments I agree the original approach was off: Schema FQCN — you're right. Objects already live in the
What I kept instead — fixing actual short-name usages in core code. A repo-wide search turned up two remaining call sites that still passed bare
Pushed in Happy to dig further if you know of other profiler warnings I missed — I didn't have a concrete stack trace in the original PR, which was part of the problem. If there are more, I'd rather fix them at the call site than in schema or @Mark-H — on third-party extras using the Let me know if this direction works or if you'd prefer closing the PR and opening a smaller one with just the two call-site fixes. |
smg6511
left a comment
There was a problem hiding this comment.
@Ibochkarev My first comment is optional (but maybe preferrable), but it'd be good to know more re the modUser->getResourceGroups method — unless it's used behind the scenes somehow, we may be able to just remove that (?).
Answering my own question, this is used in one place in |
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") withMODX\\Revolution\\*equivalents. Covers modNamespace, modPlugin, modPluginEvent, modSystemSetting, modMenu, modResource, modUser, modTemplate, modChunk, modSnippet, modCategory, modContext, modEvent, modFormCustomization*, modTemplateVar*, modUserGroup*, modAccess*, and all othermod*objects in the main schema.Additionally,
modX::loadClass()now normalizes shortmod*names to FQCN at runtime. When legacy code or xPDO call paths pass short names (e.g.modResource,modAccessContext), they are converted toMODX\Revolution\*internally. Aclass_aliasis created for backward compatibility. This avoids deprecation notices fromgetObject,getCollection,newQuery, and other paths that invokeloadClassbeforemodAccessibleObject::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 withMODX\\Revolution\\*for PSR-4 autoloading. Application code already usesmodNamespace::classand 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 inloadClass()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.