Support » Plugin: Pods - Custom Content Types and Fields » Pods fetch error in PHP 5.6.25 (works fine in 5.4.16)

  • Resolved pixelkicks

    (@pixelkicks)


    I’ve been using PHP 5.4.16 for the last couple of years, with no problems at all.

    Today I changed the PHP version in Plesk on our webserver to 5.6.25, and all other sites worked fine. This particular site that uses Pods however now gives the following error:

    fatal error: Call to a member function fetch() on null

    When looking at the page source, it prints out the PHP code where I try to initiate the pod, and the error occurs when I try to run a fetch on it.

    Here’s the code I’m using. I’ve used this format on loads of other Pods sites:

    $params = array(
    		'post_status'	=> 'publish',
    		'orderby'		=> 't.ID DESC',
    		'where'			=> 'archived.meta_value = 0'
    	);
        $pod_cust = pods( 'customer', $params ); 

    What could be causing this?

    • This topic was modified 7 years, 6 months ago by pixelkicks.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Scott Kingsley Clark

    (@sc0ttkclark)

    Where is your $pod_cust->fetch() call?

    Thread Starter pixelkicks

    (@pixelkicks)

    <?php
    while ($pod_cust->fetch()) { 
    	$author_id = $pod_cust->display('post_author');
    	$author_name = get_the_author_meta( 'display_name', $author_id );
    ?>	
    			
    <tr>
    	<th><?php echo $pod_cust->display('ID'); ?></th>
    	<td><a href="/overview/?cid=<?php echo $pod_cust->display('ID'); ?>"><?php echo $pod_cust->display('post_title'); ?></a></td>															
    	<td><?php echo $author_name; ?></td>
    	<td></td>
    </tr>
    
    <?php } ?>
    Plugin Author Scott Kingsley Clark

    (@sc0ttkclark)

    It sounds like $pod_cust might be referencing a non-existent Pod. Can you confirm ‘customer’ exists? Is there any object caching enabled on the site? Do you see any other PHP notices/errors or MySQL database problems?

    Thread Starter pixelkicks

    (@pixelkicks)

    Hi Scott,

    It works perfectly if we switch to the older version of PHP though. We can literally swap back and forth between versions and it either works or doesn’t work.

    However – I’VE JUST FIXED IT… turns out it was a problem with “short_open_tag” being switched off. Why this didn’t cause a problem with PHP 5.4 I’m not sure?

    Chris.

    Plugin Author Scott Kingsley Clark

    (@sc0ttkclark)

    Must have been some php configuration difference there between versions, I know short open tag was only recently enabled by default, but it can still be disabled (and was off by default in other versions).

    Plugin Author Scott Kingsley Clark

    (@sc0ttkclark)

    I should also note that in your $params you have ‘post_status’ as an argument but that’s not being used by Pods, you’d have to add it to your ‘where’ clause.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Pods fetch error in PHP 5.6.25 (works fine in 5.4.16)’ is closed to new replies.