From dac1de24f7f93c0592860b2722e29115a248dfc0 Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Wed, 30 Sep 2015 04:53:25 +0000 Subject: [PATCH] Bail out of termmeta functions if schema is not up-to-date. Termmeta cache priming was throwing database errors on installations that had not yet gone through the database update routine. To avoid errors in all cases, the check has been added to all termmeta functions. These checks will be removed in a future version of WordPress. (Hang on to your hats!) Fixes #34091. Built from https://develop.svn.wordpress.org/trunk@34718 git-svn-id: http://core.svn.wordpress.org/trunk@34682 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/taxonomy-functions.php | 25 +++++++++++++++++++++++++ wp-includes/version.php | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/wp-includes/taxonomy-functions.php b/wp-includes/taxonomy-functions.php index 8b54693087..51ad965196 100644 --- a/wp-includes/taxonomy-functions.php +++ b/wp-includes/taxonomy-functions.php @@ -1501,6 +1501,11 @@ function get_terms( $taxonomies, $args = '' ) { * @return int|bool Meta ID on success, false on failure. */ function add_term_meta( $term_id, $meta_key, $meta_value, $unique = false ) { + // Bail if term meta table is not installed. + if ( get_option( 'db_version' ) < 34370 ) { + return false; + } + $added = add_metadata( 'term', $term_id, $meta_key, $meta_value, $unique ); // Bust term query cache. @@ -1522,6 +1527,11 @@ function add_term_meta( $term_id, $meta_key, $meta_value, $unique = false ) { * @return bool True on success, false on failure. */ function delete_term_meta( $term_id, $meta_key, $meta_value = '' ) { + // Bail if term meta table is not installed. + if ( get_option( 'db_version' ) < 34370 ) { + return false; + } + $deleted = delete_metadata( 'term', $term_id, $meta_key, $meta_value ); // Bust term query cache. @@ -1544,6 +1554,11 @@ function delete_term_meta( $term_id, $meta_key, $meta_value = '' ) { * @return mixed If `$single` is false, an array of metadata values. If `$single` is true, a single metadata value. */ function get_term_meta( $term_id, $key = '', $single = false ) { + // Bail if term meta table is not installed. + if ( get_option( 'db_version' ) < 34370 ) { + return false; + } + return get_metadata( 'term', $term_id, $key, $single ); } @@ -1563,6 +1578,11 @@ function get_term_meta( $term_id, $key = '', $single = false ) { * @return int|bool Meta ID if the key didn't previously exist. True on successful update. False on failure. */ function update_term_meta( $term_id, $meta_key, $meta_value, $prev_value = '' ) { + // Bail if term meta table is not installed. + if ( get_option( 'db_version' ) < 34370 ) { + return false; + } + $updated = update_metadata( 'term', $term_id, $meta_key, $meta_value, $prev_value ); // Bust term query cache. @@ -1585,6 +1605,11 @@ function update_term_meta( $term_id, $meta_key, $meta_value, $prev_value = '' ) * @return array|false Returns false if there is nothing to update. Returns an array of metadata on success. */ function update_termmeta_cache( $term_ids ) { + // Bail if term meta table is not installed. + if ( get_option( 'db_version' ) < 34370 ) { + return; + } + return update_meta_cache( 'term', $term_ids ); } diff --git a/wp-includes/version.php b/wp-includes/version.php index 70e0488bd8..71827ecf57 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-alpha-34717'; +$wp_version = '4.4-alpha-34718'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.