We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20135
    • 188 Posts
    In the last 24 hours, I added UpgradeMODx to a site and upgraded it from 2.3.x to 2.4 without issue, worked beautifully. Just now I've upgraded the Taxonomies snippet from 1.3.0 to 1.3.2 and I'm getting this error message which has crippled my site:
    Fatal error: Call to a member function fetchAll() on a non-object in /.../.../public_html/.../core/cache/includes/elements/modsnippet/79.include.cache.php on line 57


    This relates to the [[getPageTerms]] snippet. I've checked the db, it looks fine. The script itself looks fine. I have the snippets used extensively throughout the site, so almost every page is affected by the error. Ideas/help would be very greatly appreciated.

    (I've tried to uninstall and reinstall Taxonomies without any change. I've had to shut down that site effectively so that I can go in an comment out all of the references to the getPage snippet).

    Edit: I should also point out up front that I've cleaned out the cache manually. [ed. note: moniarde last edited this post 8 years, 7 months ago.]
      • 3749
      • 24,544 Posts
      What's the code around line 57 of the snippet with the ID 79?
        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
        • 20135
        • 188 Posts
        $results = $obj->fetchAll(PDO::FETCH_ASSOC);


        Here's the whole piece of code from the cache, duplicated from the getPageTerms snippet itself:

        <?php
        /**
         * @name getPageTerms
         * @description Returns a list of terms (e.g. a tag cloud) for the given page (e.g. resource)
         *
         * Note: this Snippet does not calculate any term hierarchies: it only displays the *exact* terms
         * associated with a given page.
         *
         * Available Placeholders
         * ---------------------------------------
         * term_id, pagetitle
         * use as [[+term_id]] on Template Parameters
         * 
         * Parameters
         * -----------------------------
         * @param textfield $outerTpl Format the Outer Wrapper of List (Optional)
         * @param textfield $innerTpl Format the Inner Item of List
         * @param numberfield $page_id get terms for this specific page
         * @param textfield $taxonomy_id limit terms to only this taxonomy
         * @param numberfield $limit Limit the result, default to 10 : setting it to 0 will show all
         *
         * Variables
         * ---------
         * @var $modx modX
         * @var $scriptProperties array
         *
         * Usage
         * ------------------------------------------------------------
         * [[!getPageTerms? &page_id=`[[+page_id]]` &outerTpl=`sometpl` &innerTpl=`othertpl` &limit=`0`]]
         *
         * @package taxonomies
         **/
        
        $core_path = $modx->getOption('taxonomies.core_path', null, MODX_CORE_PATH.'components/taxonomies/');
        require_once $core_path .'vendor/autoload.php';
        $Snippet = new \Taxonomies\Base($modx);
        $Snippet->log('getPageTerms',$scriptProperties);
        
        
        $page_id = $modx->getOption('page_id',$scriptProperties,null);
        $outerTpl = $modx->getOption('outerTpl',$scriptProperties, '<ul>[[+content]]</ul>');
        $innerTpl = $modx->getOption('innerTpl',$scriptProperties, '<li><a href="[[~[[+term_id]]]]">[[+pagetitle]]</a></li>');
        $limit = $modx->getOption('limit',$scriptProperties,10);
        $taxonomy_id = $modx->getOption('taxonomy_id',$scriptProperties,null);
        
        $limit = ($limit == 0) ? '' : 'LIMIT ' . $limit;
        $and_where = (is_null($taxonomy_id)) ? '' : 'AND doc.parent = ' . $taxonomy_id;
        $page_id = (is_null($page_id)) ? $modx->resource->get('id') : $page_id;
        
        $content_table = $modx->getTableName('modResource');
        $sql = "SELECT terms.term_id,doc.pagetitle
        		FROM tax_page_terms terms
        		LEFT JOIN  $content_table doc ON doc.id = terms.term_id
        		WHERE terms.page_id = {$page_id} {$and_where} ORDER BY terms.term_id ASC {$limit};";
        
        $obj = $modx->query($sql);
        $results = $obj->fetchAll(PDO::FETCH_ASSOC);
        
        if(count($results) == 0) {
        	$modx->log(\modX::LOG_LEVEL_DEBUG, "No results found",'','getPageTerms',__LINE__);
        }
        
        return $Snippet->format($results,$innerTpl,$outerTpl);
        return;
        
          • 3749
          • 24,544 Posts
          I don't see anything obvious, though $obj in line 56 should probably be tested with is_object(). Looks like a job for the author.
            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
            • 20135
            • 188 Posts
            Quote from: BobRay at Sep 11, 2015, 12:29 AM
            I don't see anything obvious, though $obj in line 56 should probably be tested with is_object(). Looks like a job for the author.
            Agreed. Will post to their Git.