Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Tessa (they/them), AuRise Creative

    (@tessawatkinsllc)

    Thanks for making the new thread!

    I was digging into this yesterday after your original comment on the other post, playing around with my own setup to reproduce the issue and I could reproduce something (though I was using a virtual host, but basically changed it to a port other than 80 so that it’d show up in the URL).

    I believe your $_SERVER['SERVER_NAME'] variable is set to www.argenteriadabbene.com so the previous combination of putting

    $_SERVER['SERVER_NAME'] + : + $_SERVER['SERVER_PORT'] + $_SERVER['REQUEST_URI']

    would’ve made

    www.argenteriadabbene.com + : + 443 + /it/prodotto/ricci-ascot/

    Which, without the plus signs, would’ve appropriately outputted www.argenteriadabbene.com:433/it/prodotto/ricci-ascot/ as the URL previously. As we know, that code worked for you.

    With the updated code in 3.3.0 being this:

    // Build the full URL
    if (!empty($_SERVER['SERVER_PORT']) && intval($_SERVER['SERVER_PORT']) !== 80) {
        $url = network_home_url() . ':' . $_SERVER['SERVER_PORT'] . $_SERVER['REQUEST_URI'];
    } else {
        $url = network_home_url($_SERVER['REQUEST_URI']);
    }

    And since $_SERVER['SERVER_PORT'] has a value of 443, that first if-statement is evaluating to true, with this line:

    network_home_url() + : + $_SERVER['SERVER_PORT'] + $_SERVER['REQUEST_URI']

    becoming this:

    argenteriadabbene.com/it + : + 443 + /it/prodotto/ricci-ascot/

    That makes me believe network_home_url() identifies your domain inclusive of the language directory (and without the configured www in your server name variable).

    In my local environment, I ended up with something like:

    local.aurisecreative.com:443 + : + 443 + /some-random-page/

    Since network_home_url() was also inclusive of the port. I resolved the issue that showed up in my local environment with this snippet:

    // Build the full URL
    if (!empty($_SERVER['SERVER_PORT']) && intval($_SERVER['SERVER_PORT']) !== 80 && (strpos($host = network_home_url(), $port = ':' . $_SERVER['SERVER_PORT']) === false)) {
        $url = $host . $port . $_SERVER['REQUEST_URI'];
    } else {
        $url = network_home_url($_SERVER['REQUEST_URI']);
    }

    But without having qtranslate-xt in my environment, it didn’t recreate your issue exactly, the doubling of the /it path. I’m not totally convinced this snippet would fix your problem since it’s not the port number being doubled, but the /it path.

    I’ll get the plugin in my local environment to play with it more to see if I can really reproduce your issue. I am curious to see how this plugin works!

    Plugin Author Tessa (they/them), AuRise Creative

    (@tessawatkinsllc)

    After trying a few combinations:

    1. network_home_url() = https://local.aurisecreative.com:8008/en
    2. home_url() = https://local.aurisecreative.com:8008/en
    3. $_SERVER['REQUEST_URI'] = /en/testing-dynamic-extension/
    4. network_home_url($_SERVER['REQUEST_URI']) = https://local.aurisecreative.com:8008/en/testing-dynamic-extension/
    5. network_home_url() . $_SERVER['REQUEST_URI'] = https://local.aurisecreative.com:8008/en/en/testing-dynamic-extension/
    6. network_home_url(':' . $_SERVER['SERVER_PORT'] . $_SERVER['REQUEST_URI']) = https://local.aurisecreative.com:8008/en/:8008/en/testing-dynamic-extension/

    I’ve decided to just go with #4. It would seem the built-in functions network_home_url() and home_url() both already include the port (if it is set) and the language directory from that plugin. Also, when using that function and putting in the $_SERVER['REQUEST_URI'] variable inside it, rather than after it, the function also removes the duplicate language code in the path! I suppose this means I can cut out the whole “is the port set?” if-statement and simply use the built-in function ??

    I’ll be updating the plugin shortly!

    Plugin Author Tessa (they/them), AuRise Creative

    (@tessawatkinsllc)

    I’ve put this fix in version 3.4.0. You should be good to update!

    Thread Starter mayaliny

    (@mayaliny)

    @tessawatkinsllc i’ve updated the plugin to latest version and the problem is fixed for me! thank you! you did an excellent and fast work!

    Plugin Author Tessa (they/them), AuRise Creative

    (@tessawatkinsllc)

    Glad to hear it! Thanks so much!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Version 3.3.0 breaking urls’ is closed to new replies.