function bb_cache_all_options() { $base_options = array('site_id', 'bb_db_version', 'name', 'description', 'uri_ssl', 'from_email', 'bb_auth_salt', 'bb_secure_auth_salt', 'bb_logged_in_salt', 'bb_nonce_salt', 'page_topics', 'edit_lock', 'bb_active_theme', 'active_plugins', 'mod_rewrite', 'datetime_format', 'date_format', 'avatars_show', 'avatars_default', 'avatars_rating', 'nxt_table_prefix', 'user_bbdb_name', 'user_bbdb_user', 'user_bbdb_password', 'user_bbdb_host', 'user_bbdb_charset', 'user_bbdb_collate', 'custom_user_table', 'custom_user_meta_table', 'nxt_siteurl', 'nxt_home', 'cookiedomain', 'usercookie', 'passcookie', 'authcookie', 'cookiepath', 'sitecookiepath', 'secure_auth_cookie', 'logged_in_cookie', 'admin_cookie_path', 'core_plugins_cookie_path', 'user_plugins_cookie_path', 'nxt_admin_cookie_path', 'nxt_plugins_cookie_path', 'nxtclass_mu_primary_blog_id', 'enable_loginless', 'enable_subscriptions', 'enable_xmlrpc', 'enable_pingback', 'throttle_time', 'bb_xmlrpc_allow_user_switching', 'bp_bbpress_cron', 'email_login', 'static_title', 'plugin_cookie_paths', 'nxt_roles_map', 'gmt_offset', 'timezone_string', 'name_link_profile', 'bp_bbpress_cron_check'); // Check that these aren't already in the cache $query_options = array(); foreach ($base_options as $base_option) { if (isset($bb->{$base_option})) { continue; } if (nxt_cache_get($base_option, 'bb_option_not_set')) { continue; } if (false === nxt_cache_get($base_option, 'bb_option')) { $query_options[] = $base_option; nxt_cache_set($base_option, true, 'bb_option_not_set'); } } if (!count($query_options)) { // It's all in cache return true; } $query_keys = "('" . join("','", $query_options) . "')"; global $bbdb; $results = $bbdb->get_results("SELECT `meta_key`, `meta_value` FROM `{$bbdb->meta}` WHERE `object_type` = 'bb_option' AND `meta_key` IN {$query_keys};"); if (count($base_options) === count($query_options) && (!$results || !is_array($results) || !count($results))) { // Let's assume that the options haven't been populated from the old topicmeta table if (!BB_INSTALLING && (!defined('BB_DO_NOT_UPGRADE_TOPICMETA') || !BB_DO_NOT_UPGRADE_TOPICMETA)) { $topicmeta_exists = $bbdb->query("SELECT * FROM {$bbdb->topicmeta} LIMIT 1"); if ($topicmeta_exists) { require_once BB_PATH . 'bb-admin/includes/defaults.bb-schema.php'; // Create the meta table $bbdb->query($bb_queries['meta']); // Copy options $bbdb->query("INSERT INTO `{$bbdb->meta}` (`meta_key`, `meta_value`) SELECT `meta_key`, `meta_value` FROM `{$bbdb->topicmeta}` WHERE `topic_id` = 0;"); // Copy topic meta $bbdb->query("INSERT INTO `{$bbdb->meta}` (`object_id`, `meta_key`, `meta_value`) SELECT `topic_id`, `meta_key`, `meta_value` FROM `{$bbdb->topicmeta}` WHERE `topic_id` != 0;"); // Entries with an object_id are topic meta at this stage $bbdb->query("UPDATE `{$bbdb->meta}` SET `object_type` = 'bb_topic' WHERE `object_id` != 0"); } unset($topicmeta_exists); return bb_cache_all_options(); } return false; } else { foreach ($results as $options) { nxt_cache_delete($options->meta_key, 'bb_option_not_set'); nxt_cache_set($options->meta_key, maybe_unserialize($options->meta_value), 'bb_option'); } } return true; }
unset($i); } /** * Load additional bbPress libraries */ require_once BB_PATH . BB_INC . 'functions.bb-formatting.php'; require_once BB_PATH . BB_INC . 'functions.bb-template.php'; require_once BB_PATH . BB_INC . 'functions.bb-capabilities.php'; require_once BB_PATH . BB_INC . 'class.bb-pingbacks.php'; // Cache options from the database if (!isset($bb->load_options)) { $bb->load_options = true; } if ($bb->load_options) { $bbdb->suppress_errors(); bb_cache_all_options(); $bbdb->suppress_errors(false); } /** * Set the URI and derivitaves */ if ($bb->uri = bb_get_option('uri')) { $bb->uri = rtrim(trim($bb->uri), " \t\n\r\v/") . '/'; if (preg_match('@^(https?://[^/]+)((?:/.*)*/{1,1})$@i', $bb->uri, $matches)) { // Used when setting up cookie domain $bb->domain = $matches[1]; // Used when setting up cookie paths $bb->path = $matches[2]; } unset($matches); } elseif (BB_LOAD_DEPRECATED) {