Make WordPress Core

Ticket #1109: fix_1109.patch

File fix_1109.patch, 1.1 KB (added by anonymousbugger, 21 years ago)
  • wp-admin/categories.php

    ==== Patch <fix_1109> level 1
    Source: [No source]
    Target: 1a063a9b-81f0-0310-95a4-ce76da25c4cd:/trunk:2447 [mirrored]
            (http://svn.automattic.com/wordpress/trunk)
    Log:
    Bug fix for #1109
    === wp-admin/categories.php
    ==================================================================
     
    3232        $category_nicename = sanitize_title($cat_name, $cat_ID);
    3333        $category_description = $_POST['category_description'];
    3434        $cat = intval($_POST['cat']);
     35        // Let's check if the category already exists
    3536       
     37        $cur_id = (int) $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name = '$cat_name'");
     38        if ($cur_id>0)
     39                die(sprintf(__("Cannot create category. Category named '%s' already exists"), $cat_name));
    3640        $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent) VALUES ('0', '$cat_name', '$category_nicename', '$category_description', '$cat')");
    3741       
    3842        header('Location: categories.php?message=1#addcat');