fix(manager): Honor a stored alias_visible of 0 - #17027
Open
Ibochkarev wants to merge 1 commit into
Open
Ibochkarev wants to merge 1 commit into
Ibochkarev wants to merge 1 commit into
Conversation
parseInt() on the boolean from the resource form is NaN, and NaN || 1 checks the box even when the resource was saved with the flag off. The next save writes 1 and rebuilds the URI with the parent alias. Treat false, 0, and "0" as unchecked. A missing value stays checked, matching the column default. Fixes modxcms#14816
Ibochkarev
marked this pull request as ready for review
September 21, 2026 12:49
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed and why
The resource form checkbox "Use current alias in alias path" opened checked even when
alias_visiblewas off.create.class.phpandupdate.class.phpsend that field as a boolean.parseInt(true)andparseInt(false)are bothNaN, andNaN || 1is1. A stored0takes the same path, because0 || 1is1. The next save wrote1, andgetAliasPath()put the parent alias back into the URI.The checkbox stays off for
false,0, and"0". If the value is missing, it still starts checked, same as the column default of1. The per-resource flag stays.getAliasPath()still skips a parent only when that flag is off.Joshua Luckers pointed at this line in
modx.panel.resource.js. Jako's guess aboutphptype="boolean"andparseIntmatches the value the controllers put on the form.How to test
Open a resource with
alias_visibleset to0. The checkbox should be off. Save without touching it, and the value should stay0.Create a resource. The checkbox should start on. After save,
alias_visibleshould be1, and withuse_alias_pathon a child URI should include the parent alias.Uncheck the box, save, and open the resource again. The box should still be off.
Related issue(s)/PR(s)
Resolves #14816
Compatibility notes
This is the resource edit form in the manager. Quick create in the tree already read the raw value and is unchanged. There is no schema change and no upgrade script. Rows already stored as
0stay0until someone checks the box and saves. That includes containers created on a fresh 2.7.2 install, where the box was off and the URI was stored without the parent alias.Breaking change assessment
No public API change. New resources still default to on. A resource saved with the box off keeps that value on the next save.
Test coverage
No test added. There is no JS test harness for this manager checkbox. The change is the
checkedexpression inmanager/assets/modext/widgets/resource/modx.panel.resource.js.Contributors
@JoshuaLuckers found the line. @Jako connected
phptype="boolean"withparseInt. @Mark-H asked to leave the per-resource flag in place and to default the box to checked.AI tool use
Cursor traced the form field against the discussion on #14816 and drafted the
checkedexpression. The diff was reviewed so the commit only changes that expression.