Support has been upgraded!
The Support Forum is closed. Not to worry! Providing the top quality support you expect and we're known for will continue! We're not ending support, just changing where you submit requests. This will provide you with the best experience possible.
Premium Support
Have you purchased an addon for Connections such as one of our premium templates or extensions with a valid license and you need help?
Please open a Support Ticket in your user account.
Free Support
Are you using the free Connections plugin? Don't worry, you are still very important to us! We are still providing you with the same high quality support that we're known for.
Please open a new support topic in the WordPress support forums for Connections.
Tagged: 8.5.1, error, php, plugin conflict, theme conflict
- This topic has 24 replies, 2 voices, and was last updated 10 years, 9 months ago by
Steven Zahm.
-
AuthorPosts
-
10/17/2015 at 5:58 pm #350884
SnailsFromJupiter
GuestWhen I try to load a page that doesn’t exist inside a browser the following error displayed all over the page:
Notice: Trying to get property of non-object in <WEBROOT>/wp-content/plugins/connections/includes/class.seo.php on line 365It refers to this line of code in class.seo.php:
if ( ! is_object( $post ) || $wp_query->post->ID != $id || ! self::$filterPermalink ) return $title;Which is from the function
filterPostTitle()10/19/2015 at 10:25 am #350940Steven Zahm
Keymaster@ SnailsFromJupiter
My best guess is that the theme or another plugin is incorrectly (meaning something that should not be done) unsetting the
$wp_queryvariable.My suggestion… deactivate all plugins unrelated to Connections.
Does the error go away?
- If it does, then one of the deactivated plugin is causing the error. Here’s how to find out which one:
- Activate plugins one at a time checking for the error after each plugin activation. When the error happens again, the last plugin is the cause. If you find out which one, please let me know.
- If it does not, then the theme is the cause of the error. Here’s how to find out:
- Temporarily activate the default WordPress theme and check for the error. If it is the theme, please let me know which one you are using.
Hope that helps!
10/19/2015 at 10:27 pm #351016SnailsFromJupiter
GuestI added this fix to class.seo.php. I added this after the offending line.
if ( ! is_object( $post ) || $wp_query->post->ID != $id || ! self::$filterPermalink ) return $title;This makes sense anyway. You shouldn’t be checking
$wp_query->post->IDif you don’t know whether$wp_query->postis null or not. No assumptions should ever be made in coding. In theory it looks likefilterPostTitle()is some kind of callback that can only ever be called for posts, however it looks like it is being called in some other context. Either way it is defensive programming to add this fix. For example even if it is another plugin, it stops your plugin breaking due to the fault of another plugin.10/20/2015 at 10:41 am #351118Steven Zahm
Keymaster@ SnailsFromJupiter
I already added an additional check for this as well as a few other items I saw that could use a bit more “hardening” when reviewing this issue. The next release planned for release on Friday/this weekend will contain these changes.
Like I said though, this is not a bug with Connections, so, you really should invest the time to track down the source of the issue as suggested in my previous reply as this could easily cause you other issues down the road that may not be as readily apparent.
Cheers!
10/20/2015 at 10:53 am #351120SnailsFromJupiter
GuestThanks Steven. Hugely appreciated. You are uber efficient.
You are absolutely right about me needing to track down the cause of the issue. Just because we’ve managed to make the code cope gracefully doesn’t mean the root cause has been fixed.
I will do as you said and try disabling other plugins to see what is making this happen. Sherlock Holmes to the rescue :-)
10/20/2015 at 11:09 am #351121Steven Zahm
Keymaster@ SnailsFromJupiter
Let me know what you find, I’ll document it as plugin/theme conflict if it applies.
Let me know if my fix keeps Connections from throwing an error after you update. Thanks!
10/20/2015 at 5:23 pm #351179SnailsFromJupiter
GuestI deactivated all the plugins but the problem still occurred. Something isn’t quite right. It’s really difficult to track down. I wrote out some backtrace output in PHP to find the offending issue, however it’s quite complicated to work out what is truly at fault.
I think I need to duplicate my entire website elsewhere by copying files and database… and then completely deconstruct it back to the basic core WordPress website. That way I can hopefully track down the exact issue.
I’m probably too new at using WordPress to get into the depths right now to fix this. It could take me two months to fix this and I haven’t got time, however I am concerned to leave it as it is. I guess it will have to remain a bug to fix in the future for now.
10/21/2015 at 9:24 am #351228Steven Zahm
Keymaster@ SnailsFromJupiter
If deactivating all the plugins does not resolve it, then it must be the theme. Did you try to temporarily switch back to the default WP theme?
Which theme are you using? Is it freely available? If it is, I’ll download it and give it a look.
I’m not sure a backtrace would be too useful. I would do a multi-file search (using Sublime Text) for
$wp_queryin the theme. Look for any instance where it might being set to null, unset or overwritten. Only core WP should set up this global var, I’ve come across other theme’s which overwrite this global, unset it and set it to null… likely following some of the older tutorials that exist on the web (it use to be the only way to reliable to multiple custom post loops).10/21/2015 at 9:33 pm #351284SnailsFromJupiter
GuestI love Sublime Text!
Thanks for the tips… you’ve really helped me save time here. I feel I’m getting closer.
I’ll keep you posted.
:-)
10/21/2015 at 10:04 pm #351285SnailsFromJupiter
GuestHi Steven
The theme is called Colormag. I am using the free version. The 404 behaved correctly on a new WordPress locally hosted site which used Colormag. i.e. the issue that was triggering the issue with Connections did not occur.
I couldn’t find any places where $wp_content was being set to null.
I’ve just tested on them Twenty Fifteen and the issue still occurred. So it isn’t Colormag specific.
I’ve changed your code as follows in the function
filterPostTitle()in class.seo.php.REPLACE:
if ( ! is_object( $post ) || $wp_query->post->ID != $id || ! self::$filterPermalink ) return $title;WITH:
$post_id = get_queried_object_id(); if ( ! is_object( $post ) || $post_id != $id || ! self::$filterPermalink ) return $title;I’m not saying this is a fix, as I’m a novice. I’m just wondering why this would work? It intuitively feels to me that this either:
- The callback is getting called when something isn’t a post and so
$wp_query->postis not set OR - Something is unsetting or nulling
$wp_query->postOR - The callback is being correctly called and $wp_query->post is a known unreliable way to access the current post object
These are all guesses… can you give me some clues as to what might be going on? I’m sure your code is sound… I just need to double check with you so that we are keeping this water tight… so I can ensure the ‘leak’ is elsewhere (please excuse my flaky metaphor).
- If it does, then one of the deactivated plugin is causing the error. Here’s how to find out which one:
-
AuthorPosts
You cannot reply to this support topic. Please open your own support topic.
