From a771c948769de3bdad7189003c8c4cf64a0a0954 Mon Sep 17 00:00:00 2001 From: garvinhicking Date: Sat, 1 Apr 2006 20:24:28 +0000 Subject: [PATCH] * Create a new index on the plugin DB table, optimize fetching config values for plugins. Load language file when permissions could not allow reading the config file. (garvinhicking) --- include/functions_config.inc.php | 9 +++++- serendipity_config.inc.php | 28 +++++++++++++------ sql/db_update_1.1-alpha1_1.1-alpha2_mysql.sql | 1 + 3 files changed, 28 insertions(+), 10 deletions(-) create mode 100644 sql/db_update_1.1-alpha1_1.1-alpha2_mysql.sql diff --git a/include/functions_config.inc.php b/include/functions_config.inc.php index 6ba8bf0..b1da2d1 100644 --- a/include/functions_config.inc.php +++ b/include/functions_config.inc.php @@ -2,6 +2,11 @@ # Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team) # All rights reserved. See LICENSE file for licensing details +if (defined('S9Y_FRAMEWORK_CONFIG')) { + return; +} +@define('S9Y_FRAMEWORK_CONFIG', true); + /** * Adds a new author account * @@ -142,6 +147,8 @@ function serendipity_get_user_config_var($name, $authorid, $default = '') { $author_sql = ''; if (!empty($authorid)) { $author_sql = "authorid = " . (int)$authorid . " AND "; + } elseif (isset($serendipity[$name])) { + return $serendipity[$name]; } $r = serendipity_db_query("SELECT value FROM {$serendipity['dbPrefix']}config WHERE $author_sql name = '" . $name . "' LIMIT 1", true); @@ -512,7 +519,7 @@ function serendipity_is_iframe() { global $serendipity; if ($serendipity['GET']['is_iframe'] && is_array($_SESSION['save_entry'])) { - include_once S9Y_INCLUDE_PATH . 'include/functions_entries_admin.inc.php'; + include S9Y_INCLUDE_PATH . 'include/functions_entries_admin.inc.php'; // An iframe may NOT contain and tags, that's why we emit different headers here than on serendipity_admin.php // We need to restore GET/POST variables to that depending plugins inside the iframe diff --git a/serendipity_config.inc.php b/serendipity_config.inc.php index cb28614..1ad5354 100644 --- a/serendipity_config.inc.php +++ b/serendipity_config.inc.php @@ -2,6 +2,12 @@ # Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team) # All rights reserved. See LICENSE file for licensing details +if (defined('S9Y_FRAMEWORK')) { + return; +} + +@define('S9Y_FRAMEWORK', true); + if (!headers_sent()) { session_start(); } @@ -18,10 +24,10 @@ if (IS_installed === true && !defined('IN_serendipity')) { define('IN_serendipity', true); } -include_once(S9Y_INCLUDE_PATH . 'include/compat.inc.php'); +include(S9Y_INCLUDE_PATH . 'include/compat.inc.php'); // The version string -$serendipity['version'] = '1.1-alpha1'; +$serendipity['version'] = '1.1-alpha2'; // Name of folder for the default theme $serendipity['defaultTemplate'] = 'carl_contest'; @@ -176,21 +182,25 @@ if (file_exists($_SERVER['DOCUMENT_ROOT'] . dirname($_SERVER['PHP_SELF']) . '/se $local_config = S9Y_INCLUDE_PATH . '/serendipity_config_local.inc.php'; } -if (is_readable($local_config)) { - include_once($local_config); -} else { - serendipity_die(sprintf(INCLUDE_ERROR, $local_config)); +if (!is_readable($local_config)) { + $serendipity['lang'] = 'en'; + include(S9Y_INCLUDE_PATH . 'include/lang.inc.php'); + serendipity_die(sprintf(INCLUDE_ERROR . '
' . FILE_CREATE_YOURSELF, $local_config)); } +include($local_config); + define('IS_up2date', version_compare($serendipity['version'], $serendipity['versionInstalled'], '<=')); /* * Include main functions */ -include_once(S9Y_INCLUDE_PATH . 'include/functions.inc.php'); +include(S9Y_INCLUDE_PATH . 'include/functions.inc.php'); -if (serendipity_FUNCTIONS_LOADED!== true) { - serendipity_die(sprintf(INCLUDE_ERROR, 'include/functions.inc.php')); +if (serendipity_FUNCTIONS_LOADED !== true) { + $serendipity['lang'] = 'en'; + include(S9Y_INCLUDE_PATH . 'include/lang.inc.php'); + serendipity_die(sprintf(INCLUDE_ERROR . '
' . FILE_CREATE_YOURSELF, 'include/functions.inc.php')); } /* diff --git a/sql/db_update_1.1-alpha1_1.1-alpha2_mysql.sql b/sql/db_update_1.1-alpha1_1.1-alpha2_mysql.sql new file mode 100644 index 0000000..ccf1d4a --- /dev/null +++ b/sql/db_update_1.1-alpha1_1.1-alpha2_mysql.sql @@ -0,0 +1 @@ +CREATE INDEX pluginretr_idx ON {PREFIX}plugins (placement, sort_order); -- 2.39.5