From 51b6d6f6eab9ce049eb5b65a7a78cf250773f2d7 Mon Sep 17 00:00:00 2001 From: ryan Date: Fri, 24 Aug 2007 18:41:01 +0000 Subject: [PATCH] Don't pass cat as ref. Fix some term sanitization. fixes #4702 git-svn-id: http://svn.automattic.com/wordpress/trunk@5938 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/taxonomy.php | 8 ++------ wp-includes/category.php | 4 ++-- wp-includes/taxonomy.php | 7 ++----- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/wp-admin/includes/taxonomy.php b/wp-admin/includes/taxonomy.php index ca670ab67d..f74e5e3269 100644 --- a/wp-admin/includes/taxonomy.php +++ b/wp-admin/includes/taxonomy.php @@ -12,11 +12,7 @@ function category_exists($cat_name) { } function get_category_to_edit( $id ) { - $category = get_category( $id ); - - $category->term_id = (int) $category->term_id; - $category->parent = (int) $category->parent; - + $category = get_category( $id, OBJECT, 'edit' ); return $category; } @@ -90,7 +86,7 @@ function wp_insert_category($catarr) { $description = apply_filters('pre_category_description', $description); $parent = (int) $parent; - if ( empty($parent) || !get_category( $parent ) || ($cat_ID && cat_is_ancestor_of($cat_ID, $parent) ) ) + if ( empty($parent) || !category_exists( $parent ) || ($cat_ID && cat_is_ancestor_of($cat_ID, $parent) ) ) $parent = 0; $args = compact('name', 'slug', 'parent', 'description'); diff --git a/wp-includes/category.php b/wp-includes/category.php index 030572b57f..4117470198 100644 --- a/wp-includes/category.php +++ b/wp-includes/category.php @@ -28,8 +28,8 @@ function &get_categories($args = '') { // Retrieves category data given a category ID or category object. // Handles category caching. -function &get_category(&$category, $output = OBJECT) { - $category = get_term($category, 'category', $output); +function &get_category($category, $output = OBJECT, $filter = 'raw') { + $category = get_term($category, 'category', $output, $filter); _make_cat_compat($category); diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index 51c590ca45..d772b388de 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -229,7 +229,7 @@ function get_objects_in_term( $terms, $taxonomies, $args = array() ) { * This won't appear but just a note to say that this is all conjecture and parts or whole * might be inaccurate or wrong. */ -function &get_term(&$term, $taxonomy, $output = OBJECT, $filter = 'raw') { +function &get_term($term, $taxonomy, $output = OBJECT, $filter = 'raw') { global $wpdb; if ( empty($term) ) @@ -884,8 +884,6 @@ function wp_update_term( $term, $taxonomy, $args = array() ) { // First, get all of the original args $term = get_term ($term_id, $taxonomy, ARRAY_A); - $term = sanitize_term($term, $taxonomy, 'db'); - // Escape data pulled from DB. $term = add_magic_quotes($term); @@ -894,12 +892,11 @@ function wp_update_term( $term, $taxonomy, $args = array() ) { $defaults = array( 'alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => ''); $args = wp_parse_args($args, $defaults); + $args = sanitize_term($args, $taxonomy, 'db'); extract($args, EXTR_SKIP); if ( empty($slug) ) $slug = sanitize_title($name); - else - $slug = sanitize_title($slug); if ( $alias_of ) { $alias = $wpdb->fetch_row("SELECT term_id, term_group FROM $wpdb->terms WHERE slug = '$alias_of'");