From d5a6a1ab44ac1ec8697c30a187a8f51212b7ce00 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 23 Mar 2021 13:55:03 +0000 Subject: [PATCH] Taxonomy: Use a consistent check for the `$rewrite['hierarchical']` parameter. This avoids a "Trying to access array offset on value of type bool" PHP warning in `get_term_link()` if the `$rewrite` parameter of `register_taxonomy()` is set as `false`. Props Tkama, SergeyBiryukov. Fixes #52882. Built from https://develop.svn.wordpress.org/trunk@50565 git-svn-id: http://core.svn.wordpress.org/trunk@50178 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-query.php | 2 +- wp-includes/taxonomy.php | 2 +- wp-includes/version.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/wp-includes/class-wp-query.php b/wp-includes/class-wp-query.php index 339acdb520..8f26786c91 100644 --- a/wp-includes/class-wp-query.php +++ b/wp-includes/class-wp-query.php @@ -1118,7 +1118,7 @@ class WP_Query { 'field' => 'slug', ); - if ( isset( $t->rewrite['hierarchical'] ) && $t->rewrite['hierarchical'] ) { + if ( ! empty( $t->rewrite['hierarchical'] ) ) { $q[ $t->query_var ] = wp_basename( $q[ $t->query_var ] ); } diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index 7bf2fae19d..d9dd34ccf5 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -4475,7 +4475,7 @@ function get_term_link( $term, $taxonomy = '' ) { } $termlink = home_url( $termlink ); } else { - if ( $t->rewrite['hierarchical'] ) { + if ( ! empty( $t->rewrite['hierarchical'] ) ) { $hierarchical_slugs = array(); $ancestors = get_ancestors( $term->term_id, $taxonomy, 'taxonomy' ); foreach ( (array) $ancestors as $ancestor ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index c87c81ea7a..bc1f126c99 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.8-alpha-50564'; +$wp_version = '5.8-alpha-50565'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.