We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36926
    • 701 Posts
    I had a similar issue. But that was caused the pdoMenu being called cached. So if a visitor happened to visit a page first after a resent clear cache of the site they'd then set all the links on any page they visited first to https.

    The way around it was I just added in a htaccess rule so https redirected to http and then cleared cache.
      • 46039
      • 76 Posts
      bennyb that is very interesting. Which version of MODX did it happen to?
        • 46039
        • 76 Posts
        Anyone got any further ideas of where to look for this issue?
          • 17301
          • 932 Posts
          Is everything being called uncached that would effect links? base href/pdoMenu/wayFinder/getResources etc? Is there any kind of pattern on what links are swapping to and from https?
            ■ email: [email protected] | ■ website: https://alienbuild.uk

            The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
            • 46039
            • 76 Posts
            Removing this as it may cause confusion for googlers. As I had not removed all inline scheme calls at this point and it was masking the core issue which I found after posting, as outlined in the answer below. [ed. note: johnnyp last edited this post 7 years, 1 month ago.]
              • 3749
              • 24,544 Posts
              Do you have the link_tag_scheme System Setting set to https? If not, try that.

              Also, make sure you have a rewrite rule in .htaccess that forces everyone to https.
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 46039
                • 76 Posts
                Hey Bob, the issue is the site does not have SSL and is http only. link_tag_scheme is -1 but changing it doesn't fix the issue.

                I understand the way the site is set up without SSL while allowing https connections is not ideal, but it cannot be changed. My main concern is that MODX is not behaving in the way I would expect when building URLs.
                • discuss.answer
                  • 46039
                  • 76 Posts
                  This is the issue I'm experiencing. https://github.com/modxcms/revolution/issues/6034

                  Since I've been auditing the site and removing inline scheme directives I've noticed that it is primarily when building with [[~1]] with no inline scheme that is causing issues.

                  Turns out MODX doesn't support relative site root URLs when using -1 unless you double up and write in the scheme inline (~1? &scheme=`-1`). This is due to what I personally feel to be a bug in the code, described below.

                  That means that any instance of [[~1]] is built as an absolute URL and cached by the first person to visit, with the protocol they happened to use.

                  Looking at the code this honestly does look like a bug, because someone has assumed -1 would always be INT in multiple places. Both in the site_start check AND in the later host building block with the switch too (good job the switch doesn't have a default). The absolute URL that results seems to be a side effect of an empty url var. Why would you test for -1 but not '-1' if this was a purposeful effect? And why not just fix this instead of making jokes on the ticket?

                  The issue is obvious if you look in modcontext.class.php
                  ((integer) $id === (integer) $config['site_start']) {
                  As it doesn't handle STRINGS, only integer instances of the -1 arg. All that needs to be done is a STRING equivalent test for '-1' performed alongside each integer test. None of the later code does anything to links with the -1 scheme, it just prepends an empty host string.

                  It is easier to just set the global setting to 'abs' to get around this on a basic site, but that does not excuse the bug. [ed. note: johnnyp last edited this post 7 years, 1 month ago.]
                    • 3749
                    • 24,544 Posts
                    Good detective work. Could you file that here: http://tracker.modx.com/
                      Did I help you? Buy me a beer
                      Get my Book: MODX:The Official Guide
                      MODX info for everyone: http://bobsguides.com/modx.html
                      My MODX Extras
                      Bob's Guides is now hosted at A2 MODX Hosting