Support » Plugins » [Plugin: WPtouch iPhone Theme] WPTouch Call to a member function get()

  • I’m running WordPress 2.6.3, and tried installing the latest version of WPTouch on my Dev copy of my site. It returns:

    Fatal error: Call to a member function get() on a non-object in /home/geeksho1/public_html/newdev/wp-includes/query.php on line 10

    However, on my WP2.5 install, it works fine. Any chance for a fix coming down the pipeline? I’ll be swapping out versions in the next month or so, and I’m hoping to continue using this plugin on the new version…

Viewing 9 replies - 1 through 9 (of 9 total)
  • The same error happened to me on a 2.6.3 WP version. It seems there’s a conflict with other plugins. In my case was the Podcasting plugin, 2.0b4 version. My suspect is that there’s a conflict with the WP query made by Podcast to create a podcast feed, but I’ve no elements to confirm this.
    I wrote an email on 10/28 to the WPtouch plugin authors to report the bug and they answered “we’ll look into it”.
    Today they released a new version, but at the moment I don’t know if this problem was fixed. I will make a test later.
    Do you also have installed the Podcast plugin or something similar that creates / modifies WP query?

    Ok, I made a test with a clean install of WP 2.3.5. No plugins installed (no akismet, no hello dolly), default theme, no permalinks set. Only Podcasting and WpTouch.

    These are the steps:
    1st attempt
    I installed Podcasting 2.0b4 and WPTouch 1.4.
    Activated Podcasting, OK.
    Activated WPTouch: Fatal error: …

    Deactivated both

    2nd attempt (same plugin versions)
    Activated WPTouch, OK.
    Activated Podcasting: Fatal error: …

    Upgraded both plugins (respectively to 2.0b7 and 1.5 version), I made the same steps as above with upgraded versions, but the problem still remains.

    I did some substantial testing this morning regarding this issue. Essentially, the error message you are seeing is related to this line in WordPress:

    return $wp_query->get($var);

    What the error says is the object $wp_query does not exist when this line is run.

    Looking at my code, it is indeed my plugin that is running this line in the get_query_var function. I use that WordPress function to determine the feed type. However, this WordPress function should always work, provided WordPress is loaded.

    Looking closer into the WPTouch plugin reveals that the plugin is not using the standard WordPress API for database calls. What’s worse is the plugin switches the database several times away from WordPress, breaking the WordPress $wp_query object until WordPress has a chance to reinitialize it.

    This is what is causing the issue with the two plugins. I’m not sure how to resolve the issue in WPTouch, other than rewriting the queries, but that is most likely what needs to be done.

    Cavemonkey50 you’re right.
    This afternoon I made other tests on the conflict between WPTouch and Podcasting plugin, with a clean install of WP 2.3.5. No other plugins installed (no akismet, no hello dolly), default theme, no permalinks set. Only Podcasting and WpTouch.
    I tried with latest versions of both plugins and I found where the
    problem happens.
    Podcasting plugin uses this hook to modify the blog name in the Rss Feed:

    add_filter('option_blogname', 'podcasting_blogname_filter');

    the function is:

    // Change the podcast title
    function podcasting_blogname_filter($title) {
           if ( 'podcast' == get_query_var('feed') ) {
           // [cut]
           return $title;

    when you activate WPTouch, the get_query_var function does not work. In fact, if you comment the hook this way

    // add_filter('option_blogname', 'podcasting_blogname_filter');

    everything works fine.
    I noticed too the non standard use of DB queries, but I didn’t try because I thought that was something related to WPT plugin hooks.
    I wrote also an email to the WPTouch author, meanwhile I will try to patch the non standard queries.

    Thanks for your reply!


    I’ve found the problem in WPtouch. It’s caused not by hardcoded mysql queries, but by these rows right at the top of the wptouch.php file:

    $bnc_option = get_option('bnc_iphone_pages');
    if ($bnc_option == null) {
    	$defaults = array();
    	$defaults['header-background-color'] = '222222';
    	$defaults['header-title'] = '' . get_bloginfo('title') . ''; // this one

    the row with get_bloginfo('title'). If you comment it, it works.

    Maybe the cause is that this code is not contained in a function hooked to a WP API.

    In fact, if you wrap those lines in a function, and you hook to init filter it works:

    function bnc_myWPT(){
    $bnc_option = get_option('bnc_iphone_pages');
    	if ($bnc_option == null) {
    		$defaults = array();
    		$defaults['header-background-color'] = '222222';
    		$defaults['header-title'] = '' . get_bloginfo('title') . '';
    add_filter('init', 'bnc_myWPT');

    Tomorrow I’ll send an email to the plugin author to report the issue (he didn’t answered to me yet).
    Hope it helps!

    Ah, yes, that would be the problem. That line of code does need to be in an init. If the blog title is run before WordPress is fully loaded, my plugin then fires to see if it needs to filter the blog title, and since WordPress isn’t done loading, we have problems.

    Great find mrbrown.

    Thanks cavemonkey50,

    it seems that the original get_bloginfo function (not hooked to init) creates the conflict only with certain parameters.


    Just for info, all parameters related to RSS Feeds generate a different error:

    Fatal error: Call to a member function get_feed_permastruct() on a non-object in ...

    The strange thing is that the title parameter in the Codex does not exists, so all get_bloginfo('title') calls should be replaced with get_bloginfo('name')

    Anyway Dale, one of the WPtouch authors, answered to me that they look into it soon, so until they fix the problem we at least have a patch.


    Thanks for the information, guys. Good detective work. Way beyond what I would have been able to do on my own. 🙂

    Hi all, sorry we didn’t see this thread earlier. We’ll certainly resolve the issue.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Plugin: WPtouch iPhone Theme] WPTouch Call to a member function get()’ is closed to new replies.