Unusual requests triggering fatal errors
-
I’m seeing PHP fatal errors triggered by unexpected requests when the plugin is activated.
curl -v "http://localhost/?s=n&audience=x"PHP Fatal error: Uncaught TypeError: trim(): Argument #1 ($string) must be of type string, WP_Error given in /var/www/html/wp-content/plugins/wonderm00ns-simple-facebook-open-graph-tags/public/class-webdados-fb-open-graph-public.php:739
Stack trace:
#0 /var/www/html/wp-content/plugins/wonderm00ns-simple-facebook-open-graph-tags/public/class-webdados-fb-open-graph-public.php(739): trim()
#1 /var/www/html/wp-includes/class-wp-hook.php(341): Webdados_FB_Public->insert_meta_tags()
#2 /var/www/html/wp-includes/class-wp-hook.php(365): WP_Hook->apply_filters()
#3 /var/www/html/wp-includes/plugin.php(522): WP_Hook->do_action()
#4 /var/www/html/wp-includes/general-template.php(3197): do_action()
#5 /var/www/html/wp-content/themes/theme-child/templates/layouts/main.php(10): wp_head()
#6 /var/www/html/wp-includes/template-loader.php(132): include('...')
#7 /var/www/html/wp-blog-header.php(19): require_once('...')
#8 /var/www/html/index.php(17): require('...')The following line change – checking if
$term->taxonomyis available before using it, seems to prevent the fatal error in this specific case.--- a/public/class-webdados-fb-open-graph-public.php
+++ b/public/class-webdados-fb-open-graph-public.php
@@ -396,7 +396,7 @@ if ( ! class_exists( 'Webdados_FB_Public' ) ) :
} elseif ( is_tax() ) {
$fb_title = wp_strip_all_tags( stripslashes( single_term_title( '', false ) ), true );
$term = $wp_query->get_queried_object();
- $fb_url = get_term_link( $term, $term->taxonomy );
+ $fb_url = ( isset( $term->taxonomy ) ) ? get_term_link( $term, $term->taxonomy ) : $fb_url;
$debug[] = 'is_tax: ' . $term->taxonomy;
$tax_desc = trim( wp_strip_all_tags( stripslashes( term_description() ), true ) );
if ( '' != trim( $tax_desc ) ) {
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
You must be logged in to reply to this topic.