From 55a1de9b4feef8027f97e9d9d60353cc16eb5d47 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 13 Apr 2015 01:21:27 +0000 Subject: [PATCH] `wp_update_term()` should check if `get_term()` returned null. props dlh. fixes #31954. Built from https://develop.svn.wordpress.org/trunk@32117 git-svn-id: http://core.svn.wordpress.org/trunk@32096 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/taxonomy.php | 14 ++++++++++---- wp-includes/version.php | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index c1c3f99679..cce486786b 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -3365,16 +3365,22 @@ function wp_unique_term_slug($slug, $term) { function wp_update_term( $term_id, $taxonomy, $args = array() ) { global $wpdb; - if ( ! taxonomy_exists($taxonomy) ) - return new WP_Error('invalid_taxonomy', __('Invalid taxonomy')); + if ( ! taxonomy_exists( $taxonomy ) ) { + return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy' ) ); + } $term_id = (int) $term_id; // First, get all of the original args - $term = get_term ($term_id, $taxonomy, ARRAY_A); + $term = get_term( $term_id, $taxonomy, ARRAY_A ); - if ( is_wp_error( $term ) ) + if ( is_wp_error( $term ) ) { return $term; + } + + if ( ! $term ) { + return new WP_Error( 'invalid_term', __( 'Empty Term' ) ); + } // Escape data pulled from DB. $term = wp_slash($term); diff --git a/wp-includes/version.php b/wp-includes/version.php index ca2360ce3e..172fcd9e6e 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.2-beta4-32116'; +$wp_version = '4.2-beta4-32117'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.