mirror of
https://github.com/WordPress/WordPress.git
synced 2024-10-31 15:59:44 +01:00
Changes to options system and query improvements.
git-svn-id: http://svn.automattic.com/wordpress/trunk@1401 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
50e5276b0a
commit
e2d3bb0acc
@ -841,6 +841,18 @@ function upgrade_130() {
|
||||
if(!$wpdb->get_var("SELECT option_id FROM $wpdb->options WHERE option_name = 'default_email_category'")) {
|
||||
$wpdb->query("INSERT INTO $wpdb->options (option_name, option_type, option_value, option_description, option_admin_level) VALUES('default_email_category', 1, '1', 'by default posts by email will have this category', 8)");
|
||||
}
|
||||
|
||||
if(!$wpdb->get_var("SELECT option_id FROM $wpdb->options WHERE option_name = 'recently_edited'")) {
|
||||
$wpdb->query("INSERT INTO $wpdb->options (option_name, option_type, option_value, option_admin_level) VALUES ('recently_edited', 3, '', 8)");
|
||||
}
|
||||
|
||||
maybe_add_column($wpdb->options, 'autoload', "ALTER TABLE `$wpdb->options` ADD `autoload` ENUM( 'yes', 'no' ) NOT NULL ;");
|
||||
|
||||
// Set up a few options not to load by default
|
||||
$fatoptions = array( 'moderation_keys', 'recently_edited' );
|
||||
foreach ($fatoptions as $fatoption) :
|
||||
$wpdb->query("UPDATE $wpdb->options SET `autoload` = 'no' WHERE option_name = '$fatoption'");
|
||||
endforeach;
|
||||
}
|
||||
|
||||
?>
|
@ -148,7 +148,6 @@ foreach (array_merge($wpvarstoreset, $more_wpvars) as $wpvar) {
|
||||
if ($pagenow != 'post.php') { timer_start(); }
|
||||
|
||||
// Update some caches.
|
||||
update_user_cache();
|
||||
update_category_cache();
|
||||
|
||||
// Call query posts to do the work.
|
||||
|
@ -188,7 +188,7 @@ function get_userdata($userid) {
|
||||
|
||||
function get_userdatabylogin($user_login) {
|
||||
global $cache_userdata, $wpdb;
|
||||
if ( empty($cache_userdata["$user_login"]) ) {
|
||||
if ( !empty($user_login) && empty($cache_userdata["$user_login"]) ) {
|
||||
$user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE user_login = '$user_login'");
|
||||
$cache_userdata["$user_login"] = $user;
|
||||
} else {
|
||||
@ -199,7 +199,7 @@ function get_userdatabylogin($user_login) {
|
||||
|
||||
function get_userid($user_login) {
|
||||
global $cache_userdata, $wpdb;
|
||||
if ( empty($cache_userdata["$user_login"]) ) {
|
||||
if ( !empty($user_login) && empty($cache_userdata["$user_login"]) ) {
|
||||
$user_id = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_login = '$user_login'");
|
||||
|
||||
$cache_userdata["$user_login"] = $user_id;
|
||||
@ -300,38 +300,34 @@ function url_to_postid($url = '') {
|
||||
|
||||
function get_settings($setting) {
|
||||
global $wpdb, $cache_settings;
|
||||
if (strstr($_SERVER['REQUEST_URI'], 'install.php')) {
|
||||
if ( strstr($_SERVER['REQUEST_URI'], 'install.php') || strstr($_SERVER['REQUEST_URI'], 'upgrade.php') ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( (empty($cache_settings)) ) {
|
||||
$settings = get_alloptions();
|
||||
$cache_settings = $settings;
|
||||
} else {
|
||||
$settings = $cache_settings;
|
||||
if ( empty($cache_settings) ) {
|
||||
$cache_settings = get_alloptions();
|
||||
}
|
||||
|
||||
if ('home' == $setting && '' == $settings->home) return $settings->siteurl;
|
||||
if ('home' == $setting && '' == $cache_settings->home) return $cache_settings->siteurl;
|
||||
|
||||
if (!isset($settings->$setting)) {
|
||||
return false;
|
||||
if (!isset($cache_settings->$setting)) {
|
||||
return $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = '$setting'");
|
||||
} else {
|
||||
return stripslashes($settings->$setting);
|
||||
return $cache_settings->$setting;
|
||||
}
|
||||
}
|
||||
|
||||
function get_alloptions() {
|
||||
global $wpdb;
|
||||
$options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options");
|
||||
if ($options) {
|
||||
if ($options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'")) {
|
||||
foreach ($options as $option) {
|
||||
// "When trying to design a foolproof system,
|
||||
// never underestimate the ingenuity of the fools :)"
|
||||
// never underestimate the ingenuity of the fools :)" -- Dougal
|
||||
if ('siteurl' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value);
|
||||
if ('home' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value);
|
||||
if ('category_base' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value);
|
||||
|
||||
$all_options->{$option->option_name} = $option->option_value;
|
||||
$all_options->{$option->option_name} = stripslashes($option->option_value);
|
||||
}
|
||||
}
|
||||
return $all_options;
|
||||
@ -1811,10 +1807,14 @@ function update_category_cache() {
|
||||
function update_user_cache() {
|
||||
global $cache_userdata, $wpdb;
|
||||
|
||||
$users = $wpdb->get_results("SELECT * FROM $wpdb->users WHERE user_level > 0");
|
||||
foreach ($users as $user) {
|
||||
$cache_userdata[$user->ID] = $user;
|
||||
}
|
||||
if ( $users = $wpdb->get_results("SELECT * FROM $wpdb->users WHERE user_level > 0") ) :
|
||||
foreach ($users as $user) :
|
||||
$cache_userdata[$user->ID] = $user;
|
||||
endforeach;
|
||||
return true;
|
||||
else:
|
||||
return false;
|
||||
endif;
|
||||
}
|
||||
|
||||
function wp_head() {
|
||||
|
@ -47,12 +47,6 @@ if ( !(phpversion() >= '4.1') )
|
||||
die( 'Your server is running PHP version ' . phpversion() . ' but WordPress requires at least 4.1' );
|
||||
|
||||
|
||||
$wpdb->hide_errors();
|
||||
$users = $wpdb->get_results("SELECT * FROM $wpdb->users");
|
||||
if ( !$users && !strstr($_SERVER['PHP_SELF'], 'install.php') )
|
||||
die("It doesn't look like you've installed WP yet. Try running <a href='wp-admin/install.php'>install.php</a>.");
|
||||
$wpdb->show_errors();
|
||||
|
||||
require (ABSPATH . WPINC . '/functions.php');
|
||||
require (ABSPATH . WPINC . '/functions-formatting.php');
|
||||
require (ABSPATH . WPINC . '/template-functions.php');
|
||||
@ -60,6 +54,11 @@ require (ABSPATH . WPINC . '/links.php');
|
||||
require (ABSPATH . WPINC . '/kses.php');
|
||||
require_once (ABSPATH . WPINC . '/wp-l10n.php');
|
||||
|
||||
$wpdb->hide_errors();
|
||||
if ( !update_user_cache() && !strstr($_SERVER['PHP_SELF'], 'install.php') )
|
||||
die("It doesn't look like you've installed WP yet. Try running <a href='wp-admin/install.php'>install.php</a>.");
|
||||
$wpdb->show_errors();
|
||||
|
||||
if (!strstr($_SERVER['PHP_SELF'], 'install.php') && !strstr($_SERVER['PHP_SELF'], 'wp-admin/import')) {
|
||||
|
||||
$querystring_start = '?';
|
||||
|
Loading…
Reference in New Issue
Block a user