We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29517
    • 40 Posts
    I have a number of sites running variious versions of MODx from Revo 2.1x through to 2.3.3. There have been no issues up until 2 months ago when the Wayfinder menu on a number of these sites disappeared. Clearing the cache fixes the issue temporarily but after a few weeks, the menu would disappear again.

    All these sites are hosted on the same server so I thought perhaps the server environment had changed, but I have many more Revo sites on the same server that have no Wayfinder issues. My Wayfinder call is fairly standard - something like this is typical.

    [[!Wayfinder? &startId=`0` &level=`3` &titleOfLinks=``]]


    Any ideas what is going on?
      Creative Director - Throwstone Web Design Melbourne
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Your Wayfinder is called uncached, so the menu itself is not being cached. So something is happening to either your resource cache files or the snippet's cache file. Have you looked at the server PHP error logs, or the MODX error log?

      To illustrate, here is a sample cache of the masthead/main menu part of a page with the menu snippet (I use pdoMenu) uncached - [[!pdoMenu...]]
      <!-- Navigation -->
      <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
          <div class="container">
          <!-- Brand and toggle get grouped for better mobile display -->
          <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
              <span class="sr-only">Toggle navigation</span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="http://localhost/revo24-dev/">
              <img src="http://placehold.it/150x50&text=MODX Revolution" alt="">
            </a>
          </div>
          <!-- Collect the nav links, forms, and other content for toggling -->
          <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            [[!pdoMenu? &parents=`0` &level=`1` &outerClass=`nav navbar-nav`]]
          </div> <!-- /.navbar-collapse -->
        </div> <!-- /.container -->
      </nav>
      
      


      As you can see, instead of the menu the snippet is still in the cache file. So this means that every page request this snippet will be processed. In your case, something is happening to that cache file. The next time you have a resource where the menu has died, look at the resource's cache file (core/cache/resource/web/resources/<id>.cache.php) and see if it's corrupted. Also the core/cache/includes/elements/modsnippet/<snippetID>.include.cache.php file to see if your Wayfinder snippet's cache file has been corrupted. [ed. note: sottwell last edited this post 11 years, 6 months ago.]
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 3749
        • 24,544 Posts
        Some of the early 2.x versions were subject to cache corruption. Is this happening on the 2.3 versions too?

        Are you running StatCache, CacheMaster, APC, Varnish, or anything else that might be messing with the cache?
          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
          • 37054
          • 93 Posts
          I've also just encountered this issue on 2.3.5-pl (Traditional), MySQL 5.1.73 on Apache 2 with Wayfinder 2.3.3-pl which it seems is the latest version. I'm seeing the following error in my logs

          Should add, I'm also calling the snippet uncached.

          Error @ /core/components/wayfinder/wayfinder.class.php : 190) PHP warning: Invalid argument supplied for foreach() Array expected, interger supplied.

          so the problem, at least in my case, seems to be in the loading it's cached list of docs.

          I'm not using any MODX caching addons or PHP extensions.

          Unsure where to post a bug report on this. [ed. note: freelancewebdev last edited this post 11 years, 2 months ago.]
            • 3749
            • 24,544 Posts
            I'm suspecting this bit of code in the wayfinder class file:

            /* check for cached files */
                    $cacheResults = $this->modx->getOption('cacheResults',$this->_config,true);
                    if ($cacheResults) {
                        $this->modx->getCacheManager();
                        $cache = $this->getFromCache();
                        if (!empty($cache) && !empty($cache['docs']) && !empty($cache['children'])) {
                            /* cache files are set */
                            $this->docs = $cache['docs'];
                            $this->hasChildren = $cache['children'];
                            $this->_cached = true;
                        }
                    }


            If $cache['docs'] is not an array (but also not empty), $this->docs won't be one either and the foreach loop at line 190 will throw an error.

            It might be worth trying this for the test:

            if (!empty($cache) && !empty($cache['docs']) && is_array($cache['docs']) && !empty($cache['children'])) {
              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