recent change to header.php generates errors in debug log
-
PHP engine version: 7.2.21
WordPress Core version: 5.2.2WordPress debug log contained several entries like this:
[09-Aug-2019 15:22:29 America/New_York] PHP Notice: Undefined variable: responsive_options in /var/www/vhosts/mysite.com/httpdocs/wp-content/themes/responsive/header.php on line 153Original line 153 since version 3.16
if ( ( isset( $responsive_options['site_layout_option'] ) && ( 'full-width-layout' === $responsive_options['site_layout_option'] ) && ( ! ( is_home() || is_front_page() ) ) ) || in_array( $responsive_options['blog_posts_index_layout_default'], $responsive_blog_layout_columns, true ) ) { // notice how $responsive_options key-value of 'site_layout_option' is tested prior to reference BUT the key-value of 'blog_posts_index_layout_default' is NOT tested prior to reference.Here is my patch-fix to resolve the logged error condition, which simply wraps the “in_array()” with a set of parenthesis and couples it with a respective isset for the key-value:
if ( ( isset( $responsive_options['site_layout_option'] ) && ( 'full-width-layout' === $responsive_options['site_layout_option'] ) && ( ! ( is_home() || is_front_page() ) ) ) || ( isset( $responsive_options['blog_posts_index_layout_default'] ) && in_array( $responsive_options['blog_posts_index_layout_default'], $responsive_blog_layout_columns, true ) ) ) {In addition, I would post this report in the help forum on the cyberchimps.com site but my account registration is “still pending approval”.
The topic ‘recent change to header.php generates errors in debug log’ is closed to new replies.
