use_weblink_target breaks weblink preview if target is ID or link tag
Bug report
Summary
When use_weblink_target is enabled, weblinks that use an ID or [[~ID]] format no longer work. Issue stems from the modContext class's makeUrl's handling of that variable.
Step to reproduce
Enable use_weblink_target in the system settings. Create a new Weblink with the ID of an existing resource. Save and Preview.
Observed behavior
The Weblink will take you to example.com/[[~ID]] or example.com/ID instead of the parsed link.
Expected behavior
It should work like standard weblinks and allow for the content to be parsed as a resource ID or dynamically created link.
Environment
Observed using 2.8.4 in MODX Cloud.
I'm a bit confused as to what to actual behavior should be.
Set to true if you want to have MODX link tags and makeUrl() generate links as the target URL for WebLinks. Otherwise, the internal MODX URL will be generated by link tags and the makeUrl() method.
Link to the code: https://github.com/modxcms/revolution/blob/dc2a8570d1128914e5eb3980c2fcdd260bc96ad3/core/model/modx/modcontext.class.php#L259-L266
The behavior is actually fine everywhere except when using "Preview" (aka "View") in the manager. The preview code is not processing tags if the target is specified as a MODX link tag. This used to work but changes were made to how the preview works in both 2.x and 3.x which has broken the behavior for this case.
Did an integer ID ever work as a weblink target, though?
Did an integer ID ever work as a weblink target, though?
Yes, for a regular weblink it checks if the content is an integer
Whatever happened to the preview code, since this used to work just fine, will need to be restored to solve this.
My guess is that we forgot to port PR #14954 from 2.x to 3.x
It doesn't work in 2.x or 3.x.