modxbot / migrate

A testground for migrating issues and other such fun
0 stars 0 forks source link

makeUrl should fall back to the global system setting value #10248

Open modxbot opened 11 years ago

modxbot commented 11 years ago

everettg_99 created Redmine issue ID 10248

When makeUrl is called with the scheme specified, the fallback should be the value of the _link_tagscheme system setting, but the default is hard-coded to be -1 in the function definition:

    public function makeUrl($id, $context= '', $args= '', $scheme= -1, array $options= array()) {

This puts some pretty severe limitations on URL structures of the site and causes a lot of unwanted behavior if you ever change the link_tag_scheme from anything other than -1.

h2. To Reproduce

Set the value of link_tag_scheme to "full" (or really, anything other than -1).

Somewhere in a Snippet or plugin, make use of the makeUrl() and omit the scheme argument, e.g.

$url = $modx->makeUrl(123);

h2. Expected behavior

I expect the format to follow the global system setting, e.g. http://mysite.com/path/to/my/page.html

h2. Actual behavior

The function ignores the system setting, and instead falls back to the hard-coded default value of -1

h2. Possible Fix

Fixing this without breaking backwards-compatibility I think is possible by using the func_get_args() function -- it shows only what arguments were actually sent to the function.

    public function makeUrl($id, $context= '', $args= '', $scheme= -1, array $options= array()) {
        $url= '';
        // Get system default for scheme
        $func_args = func_get_args();
        if (!isset($func_args[3])) {
            $scheme = $modx->getOption('link_tag_scheme');
        }

h2. Related?