From 5e87dfc5df1831aa491b7c36a37ae382c7570cc5 Mon Sep 17 00:00:00 2001 From: saxmatt Date: Sat, 4 Sep 2004 21:52:00 +0000 Subject: [PATCH] Remove optionvalues table. git-svn-id: http://svn.automattic.com/wordpress/trunk@1594 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/install.php | 62 ----------------- wp-admin/optionhandler.php | 64 ------------------ wp-admin/upgrade-functions.php | 117 +-------------------------------- wp-settings.php | 2 - 4 files changed, 3 insertions(+), 242 deletions(-) diff --git a/wp-admin/install.php b/wp-admin/install.php index c9722c4daf..0c7a40b33d 100644 --- a/wp-admin/install.php +++ b/wp-admin/install.php @@ -383,28 +383,6 @@ CREATE TABLE $wpdb->optiongroup_options ( "; $q = $wpdb->query($query); - -// $query = "DROP TABLE IF EXISTS $wpdb->optionvalues"; -// $q = mysql_query($query) or mysql_doh("doh, can't drop the table \"$wpdb->optionvalues\" in the database."); - -$query = " -CREATE TABLE $wpdb->optionvalues ( - option_id int(11) NOT NULL, - optionvalue tinytext, - optionvalue_desc varchar(255), - optionvalue_max int(11), - optionvalue_min int(11), - optionvalue_seq int(11), - UNIQUE (option_id, optionvalue(255)), - INDEX (option_id, optionvalue_seq) -) -"; -$q = $wpdb->query($query); - -?> - -optiontypes (optiontype_id, optiontype_name) VALUES (1, 'integer')", "INSERT INTO $wpdb->optiontypes (optiontype_id, optiontype_name) VALUES (2, 'boolean')", @@ -530,22 +508,6 @@ $option_data = array( "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(6,8,7)", "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(6,54,8)", -// select data for what to show -"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (49, 'days', 'days', null,null,1)", -"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (49, 'posts', 'posts', null,null,2)", -// select data for archive mode -"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (50, 'daily', 'daily', null,null,1)", -"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (50, 'weekly', 'weekly', null,null,2)", -"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (50, 'monthly', 'monthly', null,null,3)", -"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (50, 'postbypost','post by post',null,null,4)", -// select data for time diff -"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (51, 'hours', 'hours', 23, -23, null)", -// select data for start of week -"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (9, '0', 'Sunday', null,null,1)", -"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (9, '1', 'Monday', null,null,2)", -"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (9, '6', 'Saturday', null,null,3)", - - // Add in a new page for POST DEFAULTS // default_post_status select one of publish draft private @@ -569,25 +531,6 @@ $option_data = array( "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(7,59,5 )", "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(7,83,5 )", -// select data for post_status -"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (55, 'publish', 'Publish', null,null,1)", -"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (55, 'draft', 'Draft', null,null,2)", -"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (55, 'private', 'Private', null,null,3)", - -// select data for comment_status -"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (56, 'open', 'Open', null,null,1)", -"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (56, 'closed', 'Closed', null,null,2)", - -// select data for ping_status (aargh duplication!) -"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (57, 'open', 'Open', null,null,1)", -"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (57, 'closed', 'Closed', null,null,2)", - -// select data for pingback flag -"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (58, '1', 'Checked', null,null,1)", -"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (58, '0', 'Unchecked', null,null,2)", - -// sql select data for default -"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (59, 'SELECT cat_id AS value, cat_name AS label FROM $wpdb->categories order by cat_name', '', null,null,1)", ); foreach ($option_data as $query) { @@ -647,11 +590,6 @@ $links_option_data = array( "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(8,80,21)", "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(8,81,22)", "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(8,82,23)", - -// select data for rating_type -"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (62, 'number', 'Number', null,null,1)", -"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (62, 'char', 'Character', null,null,2)", -"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (62, 'image', 'Image', null,null,3)", ); foreach ($links_option_data as $query) { diff --git a/wp-admin/optionhandler.php b/wp-admin/optionhandler.php index c5c24101b7..3f4b88c687 100644 --- a/wp-admin/optionhandler.php +++ b/wp-admin/optionhandler.php @@ -39,60 +39,6 @@ TEXTINPUT; BOOLSELECT; //break; - - case 5: // select - $ret = << -SELECT; - - $select = $wpdb->get_results("SELECT optionvalue, optionvalue_desc " - ."FROM $wpdb->optionvalues " - ."WHERE option_id = $option_result->option_id " - ."ORDER BY optionvalue_seq"); - if ($select) { - foreach($select as $option) { - $ret .= '\n"; - } - } - $ret .= ''; - return $ret; - //break; - - case 7: // SQL select - // first get the sql to run - $sql = $wpdb->get_var("SELECT optionvalue FROM $wpdb->optionvalues WHERE option_id = $option_result->option_id"); - if (!$sql) { - return $option_result->option_name . $editable; - } - - // now we may need to do table name substitution - eval("include('../wp-config.php');\$sql = \"$sql\";"); - - $ret = << -SELECT; - - $select = $wpdb->get_results("$sql"); - if ($select) { - foreach($select as $option) { - $ret .= '\n"; - } - } - $ret .= ''; - return $ret; - //break; } // end switch return $option_result->option_name . $editable; @@ -102,16 +48,6 @@ SELECT; function validate_option($option, $name, $val) { global $wpdb; $msg = ''; - switch ($option->option_type) { - case 6: // range - // get range - $range = $wpdb->get_row("SELECT optionvalue_max, optionvalue_min FROM $wpdb->optionvalues WHERE option_id = $option->option_id"); - if ($range) { - if (($val < $range->optionvalue_min) || ($val > $range->optionvalue_max)) { - $msg = "$name is outside the valid range ($range->optionvalue_min - $range->optionvalue_max). "; - } - } - } // end switch return $msg; } // end validate_option diff --git a/wp-admin/upgrade-functions.php b/wp-admin/upgrade-functions.php index 7ec42b4221..ec04b33065 100644 --- a/wp-admin/upgrade-functions.php +++ b/wp-admin/upgrade-functions.php @@ -97,16 +97,6 @@ CREATE TABLE $wpdb->optiontypes ( optiontype_name varchar(64) NOT NULL default '', PRIMARY KEY (optiontype_id) ); -CREATE TABLE $wpdb->optionvalues ( - option_id int(11) NOT NULL default '0', - optionvalue tinytext, - optionvalue_desc varchar(255) default NULL, - optionvalue_max int(11) default NULL, - optionvalue_min int(11) default NULL, - optionvalue_seq int(11) default NULL, - UNIQUE KEY option_id (option_id,optionvalue(255)), - KEY option_id_2 (option_id,optionvalue_seq) -); CREATE TABLE $wpdb->post2cat ( rel_id int(11) NOT NULL auto_increment, post_id int(11) NOT NULL default '0', @@ -256,18 +246,6 @@ function upgrade_072() { PRIMARY KEY (group_id, option_id) ) "); - maybe_create_table($wpdb->optionvalues, " - CREATE TABLE $wpdb->optionvalues ( - option_id int(11) NOT NULL, - optionvalue tinytext, - optionvalue_desc varchar(255), - optionvalue_max int(11), - optionvalue_min int(11), - optionvalue_seq int(11), - UNIQUE (option_id, optionvalue(255)), - INDEX (option_id, optionvalue_seq) - ) - "); // TODO: REWRITE THIS $option_types = array( @@ -502,68 +480,6 @@ $guessurl = preg_replace('|/wp-admin/.*|i', '', 'http://' . $HTTP_HOST . $REQUES $wpdb->query($query); } } - - $option_values = array( - // select data for what to show - "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (49, 'days', 'days', null,null,1)", - "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (49, 'posts', 'posts', null,null,2)", - // select data for archive mode - "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (50, 'daily', 'daily', null,null,1)", - "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (50, 'weekly', 'weekly', null,null,2)", - "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (50, 'monthly', 'monthly', null,null,3)", - "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (50, 'postbypost','post by post',null,null,4)", - // select data for time diff - "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (51, 'hours', 'hours', 23, -23, null)", - // select data for start of week - "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (9, '0', 'Sunday', null,null,1)", - "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (9, '1', 'Monday', null,null,2)", - "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (9, '6', 'Saturday', null,null,3)", - - - // Add in a new page for POST DEFAULTS - - // default_post_status select one of publish draft private - // default_comment_status select one of open closed - // default_ping_status select one of open closed - // default_pingback_flag select one of checked unchecked - // default_post_category sql_select "SELECT cat_id AS value, cat_name AS label FROM $wpdb->categories order by cat_name" - - - - - // select data for post_status - "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (55, 'publish', 'Publish', null,null,1)", - "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (55, 'draft', 'Draft', null,null,2)", - "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (55, 'private', 'Private', null,null,3)", - - // select data for comment_status - "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (56, 'open', 'Open', null,null,1)", - "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (56, 'closed', 'Closed', null,null,2)", - - // select data for ping_status (aargh duplication!) - "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (57, 'open', 'Open', null,null,1)", - "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (57, 'closed', 'Closed', null,null,2)", - - // select data for pingback flag - "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (58, '1', 'Checked', null,null,1)", - "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (58, '0', 'Unchecked', null,null,2)", - - // sql select data for default - "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (59, 'SELECT cat_id AS value, cat_name AS label FROM $wpdb->categories order by cat_name', '', null,null,1)", - "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (62, 'number', 'Number', null,null,1)", - "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (62, 'char', 'Character', null,null,2)", - "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (62, 'image', 'Image', null,null,3)" - ); - - foreach ($option_values as $query) { - preg_match("|VALUES \(([0-9]+), '([^']+)'|", $query, $matches); - $option_id = $matches[1]; - $value = $matches[2]; - if(!$wpdb->get_var("SELECT * FROM $wpdb->optionvalues WHERE option_id = '$option_id' AND optionvalue = '$value'")) { - $wpdb->query($query); - } - } - if (file_exists('../wp-links/links.config.php')) { include('../wp-links/links.config.php'); @@ -635,26 +551,7 @@ function upgrade_100() { VALUES ('$gid', '$oid', '$seq')"); } - - if (!$wpdb->get_row("SELECT * FROM $wpdb->optionvalues WHERE option_id = $oid AND optionvalue = 'auto'")) { - $wpdb->query("INSERT INTO $wpdb->optionvalues - (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) - VALUES - ('$oid','auto', 'Automatic', NULL, NULL, 3)"); - } - if (!$wpdb->get_row("SELECT * FROM $wpdb->optionvalues WHERE option_id = $oid AND optionvalue = 'none'")) { - $wpdb->query("INSERT INTO $wpdb->optionvalues - (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) - VALUES - ('$oid', 'none', 'None', NULL, NULL, 1)"); - } - if (!$wpdb->get_row("SELECT * FROM $wpdb->optionvalues WHERE option_id = $oid AND optionvalue = 'manual'")) { - $wpdb->query("INSERT INTO $wpdb->optionvalues - (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) - VALUES - ('$oid', 'manual', 'Manual', NULL, NULL, 2)"); - } - + if (!$wpdb->get_var("SELECT option_id FROM $wpdb->options WHERE option_name = 'moderation_notify'")) { $wpdb->query("INSERT INTO $wpdb->options (option_id, blog_id, option_name, option_can_override, option_type, option_value, option_width, option_height, option_description, option_admin_level) @@ -720,7 +617,6 @@ function upgrade_100() { (2, $optionid, 5)"); } - $wpdb->query("UPDATE $wpdb->optionvalues SET optionvalue_max = 23 , optionvalue_min = -23 WHERE option_id = 51"); // fix upload users description $wpdb->query("UPDATE $wpdb->options SET option_description = '...or you may authorize only some users. enter their logins here, separated by spaces. if you leave this variable blank, all users who have the minimum level are authorized to upload. example: \'barbara anne george\'' WHERE option_id = 37"); // and file types @@ -774,14 +670,7 @@ function upgrade_100() { function upgrade_101() { global $wpdb; - // Fix possible duplicate problem from CVS, we can REMOVE this later - $option59 = $wpdb->get_results("SELECT * FROM $wpdb->optionvalues WHERE option_id = '59'"); - if (1 < count($option59)) { - $wpdb->query("DELETE FROM $wpdb->optionvalues WHERE option_id = '59' AND optionvalue LIKE('%FROM order%')"); - } - - // Remove 'automatic' option for comment moderation until it actually does something - $wpdb->query("DELETE FROM $wpdb->optionvalues WHERE optionvalue = 'auto'"); + // Less intrusive default $wpdb->query("ALTER TABLE `$wpdb->linkcategories` CHANGE `show_description` `show_description` ENUM( 'Y', 'N' ) DEFAULT 'N' NOT NULL"); @@ -1014,7 +903,7 @@ function upgrade_130() { update_option('active_plugins', $plugins); } - + $wpdb->query('DROP TABLE IF EXISTS ' . $table_prefix . 'optionvalues'); } // The functions we use to actually do stuff diff --git a/wp-settings.php b/wp-settings.php index c89c2b277f..fa4957c49b 100644 --- a/wp-settings.php +++ b/wp-settings.php @@ -26,7 +26,6 @@ $wpdb->links = $table_prefix . 'links'; $wpdb->linkcategories = $table_prefix . 'linkcategories'; $wpdb->options = $table_prefix . 'options'; $wpdb->optiontypes = $table_prefix . 'optiontypes'; -$wpdb->optionvalues = $table_prefix . 'optionvalues'; $wpdb->optiongroups = $table_prefix . 'optiongroups'; $wpdb->optiongroup_options = $table_prefix . 'optiongroup_options'; $wpdb->postmeta = $table_prefix . 'postmeta'; @@ -42,7 +41,6 @@ $tablelinks = $wpdb->links; $tablelinkcategories = $wpdb->linkcategories; $tableoptions = $wpdb->options; $tableoptiontypes = $wpdb->optiontypes; -$tableoptionvalues = $wpdb->optionvalues; $tableoptiongroups = $wpdb->optiongroups; $tableoptiongroup_options = $wpdb->optiongroup_options; $tablepostmeta = $wpdb->postmeta;