-
Notifications
You must be signed in to change notification settings - Fork 24
Object of class WP_Error could not be converted to string in class-wpsight-helpers.php #95
Description
Hi!
First of all - not much PHP experience, nor WordPress.
Itried to fix a page, where the plugin threw an error:
Catchable fatal error: Object of class WP_Error could not be converted to string in https://github.com/wpsight/wpcasa/blob/master/wpcasa/includes/class-wpsight-helpers.php#L680
There is a function call to get_term_link which throws. I am googled a bit, found it is a WordPress function and it has a note attached
PHP may halt if you attempt to print an error result ("Catchable fatal error: Object of class WP_Error could not be converted to string"). You should always use is_wp_error() to check the result of this function, in case the term does not exist.
https://developer.wordpress.org/reference/functions/get_term_link/#more-information
Did that.
+ if ( $linked === true && !is_wp_error(get_term_link( $term->slug, $taxonomy)) ) {
- if ( $linked === true ) {Not sure if I 'fixed' it or what potential side effects there could be, the page seems to be (mostly) working again.
Setup:
WordPress 5.2.1
PHP 7.2.18
MySQL 5.5.60
WPCasa 1.0.6.1
If you need any more Input, please let me know. I have no clue what could be important for you.