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
This commit is contained in:
Boone Gorges 2015-09-30 04:53:25 +00:00
parent 8b4c499664
commit dac1de24f7
2 changed files with 26 additions and 1 deletions

View File

@ -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 );
}

View File

@ -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.