pealo86 Posted July 26, 2011 Share Posted July 26, 2011 I've recently had my hosts upgrade PHP on my server to 5.2.17 Since that time, I am no longer able to use the get_page_by_title() function on my Wordpress Multisite. Whereever that function is used, I get an error like the following: Catchable fatal error: Object of class stdClass could not be converted to string in /var/www/vhosts/ ... If I remove that function in particular, the error goes away. So there's obviously just something about the server configuration that doesn't like this function, though I have no idea what! Has anyone else had this problem? I've had a very hard time finding similar problems on Google Quote Link to comment https://forums.phpfreaks.com/topic/242834-wordpress-get_page_by_title-generating-php-error-after-upgrading-php/ Share on other sites More sharing options...
gizmola Posted July 26, 2011 Share Posted July 26, 2011 Here's the code for the function. Check this against the code for your wordpress install. Are you using a current version or an old one? I would personally suggest putting in some debugging code to figure out what is going on. As you can see it's a pretty simple function that calls a few other functions, which could be having issues. I don't know what would happen if you encountered a database error here, say if the structure doesn't match the query. In particular, there is a parameter in this function ($output) that can control the type of return value. It is possible that your template code is expecting an array, and getting an object instead. /** * Retrieve a page given its title. * * @since 2.1.0 * @uses $wpdb * * @param string $page_title Page title * @param string $output Optional. Output type. OBJECT, ARRAY_N, or ARRAY_A. Default OBJECT. * @param string $post_type Optional. Post type. Default page. * @return mixed */ function get_page_by_title($page_title, $output = OBJECT, $post_type = 'page' ) { global $wpdb; $page = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type= %s", $page_title, $post_type ) ); if ( $page ) return get_page($page, $output); return null; } Quote Link to comment https://forums.phpfreaks.com/topic/242834-wordpress-get_page_by_title-generating-php-error-after-upgrading-php/#findComment-1247501 Share on other sites More sharing options...
pealo86 Posted July 26, 2011 Author Share Posted July 26, 2011 Ohhh I see! Thanks for the tip, funnily enough I just had to fix it using some other workaround (e.g. scrapping the template tag and finding another way of doing it). But I'll keep this in mind for next time If there is a next time! Quote Link to comment https://forums.phpfreaks.com/topic/242834-wordpress-get_page_by_title-generating-php-error-after-upgrading-php/#findComment-1247528 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.