Skip to content

fix(manager): Honor a stored alias_visible of 0 - #17027

Open
Ibochkarev wants to merge 1 commit into
modxcms:3.xfrom
Ibochkarev:fix/14816-alias-visible-checkbox
Open

Ibochkarev wants to merge 1 commit into
modxcms:3.xfrom
Ibochkarev:fix/14816-alias-visible-checkbox

Conversation

@Ibochkarev

Copy link
Copy Markdown
Collaborator

What changed and why

The resource form checkbox "Use current alias in alias path" opened checked even when alias_visible was off. create.class.php and update.class.php send that field as a boolean. parseInt(true) and parseInt(false) are both NaN, and NaN || 1 is 1. A stored 0 takes the same path, because 0 || 1 is 1. The next save wrote 1, and getAliasPath() 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 of 1. 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 about phptype="boolean" and parseInt matches the value the controllers put on the form.

How to test

Open a resource with alias_visible set to 0. The checkbox should be off. Save without touching it, and the value should stay 0.

Create a resource. The checkbox should start on. After save, alias_visible should be 1, and with use_alias_path on 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 0 stay 0 until 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 checked expression in manager/assets/modext/widgets/resource/modx.panel.resource.js.

Contributors

@JoshuaLuckers found the line. @Jako connected phptype="boolean" with parseInt. @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 checked expression. The diff was reviewed so the commit only changes that expression.

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
Ibochkarev marked this pull request as ready for review September 21, 2026 12:49
@Ibochkarev Ibochkarev added bug The issue in the code or project, which should be addressed. requires build Grunt build is required for integration type-frontend Issues related to UI/UX issues, mostly about styles and frontend implementations on JavaScript. labels Sep 21, 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. requires build Grunt build is required for integration type-frontend Issues related to UI/UX issues, mostly about styles and frontend implementations on JavaScript.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Revo 2.7.2 Fresh installation use_alias_path not working

1 participant