Don't pass cat as ref. Fix some term sanitization. fixes #4702

git-svn-id: https://develop.svn.wordpress.org/trunk@5938 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2007-08-24 18:41:01 +00:00
parent aa0ab82ecd
commit a1b51966d7
3 changed files with 6 additions and 13 deletions

View File

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

View File

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

View File

@ -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'");