We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 54111
    • 2 Posts
    In the error log for my Revo 2.5.5 site every time a new page is loaded these three errors are added to the log:

    (ERROR in modContext::makeUrl @ /home/<My Project>/public_html/core/model/modx/modcontext.class.php : 321) Resource with id 1506 was not found in context mgr

    (ERROR @ /home/<My Project>/public_html/core/model/modx/modx.class.php : 991) `` is not a valid integer and may not be passed to makeUrl()

     (ERROR @ /home/<My Project>/public_html/core/model/modx/modx.class.php : 1613) [OnPageNotFound] Plugin customUrls failed! 


    There does not appear to be anything wrong with the routing of pages or anything else and it's not a huge deal. However, since an error is added to the error log on every singe page load, the error log on my production site is over 5GB and unmanageable.

    Does anyone know what could be causing this?
      • 3749
      • 24,544 Posts
      See if the CustomUrls plugin has a return statement at the end. If not, add one.

      return;


      If that doesn't stop the makeUrl() error, you can comment out line 990 of the core/model/modx/modx.class.php file:

      // $this->log(modX::LOG_LEVEL_ERROR, '`' . $id . '` is not a valid integer and may not be passed to makeUrl()');


      It would be better to find and fix the source of the problem, but given the size of your error log, it's kind of an emergency.

      On the first error, is it always resource ID 1506? If so, does that resource exist (possibly marked for deletion or unpublished)?
        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
        • 54111
        • 2 Posts
        Sorry, should have said that its for any resource that is loaded not just #1506.

        I looked further into the customUrls plugin and it looks like the developer before me intended it to load only on Page Not Found system event (for loading variations of a single resource with custom slugs at the end)

        However the issue as far as I can tell is the plugin is being called on every single page load, not just on Page Not Found, which is causing the error build up.

        Here is the full code for the plugin:

        <?php
        error_reporting(E_ALL);
        ini_set('display_errors','1');
        
        if ($modx->event->name != 'OnPageNotFound') {return false;}
        $alias = $modx->context->getOption('request_param_alias', 'q');
        if (!isset($_REQUEST[$alias])) {return false;}
        
        $request = $_REQUEST[$alias];
        $tmp = explode('/', $request);
        //echo print_r($tmp);
        end($tmp);
        $alias = prev($tmp);
        //$modx->log(xPDO::LOG_LEVEL_DEBUG, print_r($tmp));
        $subalias = prev($tmp)."/".$alias;
        $subalias = prev($tmp)."/".$subalias;
        //$modx->log(xPDO::LOG_LEVEL_DEBUG, 'subalias+'.$subalias);
        // TODO: values mask checking!!!!
        
        $q = $modx->newQuery('modResource');
        // $tmp[5] for current degree position in tree
        //echo $subalias;
        $q->where( array('uri:LIKE' => "%".$subalias, 'template:IN' => array(22), 'context_key' => $modx->context->key) );
        //$q->where( array('alias' => $alias, 'template:IN' => array(22), 'context_key' => $modx->context->key) );
        $q->select(array('id'));
        $q->prepare();
        //$modx->log(xPDO::LOG_LEVEL_DEBUG, 'query+'.$q->toSQL());
        $q->stmt->execute();
        $cont = $q->stmt->fetch(PDO::FETCH_ASSOC);
        if(!$cont) return false;
        $_GET['type'] = $_REQUEST['type'] = end($tmp);
        $modx->sendForward($cont['id']);


        And the plug in is set to only listen to the system event OnPageNotFound.

        Any how to stop this loading on all page loads?
          • 3749
          • 24,544 Posts
          You might try putting this at the top:

          if ($modx->context->get('key') == 'mgr') {
              return;
          }


          That will prevent it from executing in the Manager, which I think is causing the page-not-found error, since there are no pages in the 'mgr' context.

          I'd also put a return statement at the end, even though it might never execute.

          Is the problem definitely happening in the front end? If so, the question is, why is MODX firing OnPageNotFound for every request?

            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