From: garvinhicking Date: Sat, 8 Mar 2008 10:27:17 +0000 (+0000) Subject: Add option to speed up joining when not needed X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=4aea0f656b85868586781e27169ee90cf9828a5e;p=s9y.git Add option to speed up joining when not needed --- diff --git a/plugins/serendipity_event_entryproperties/lang_en.inc.php b/plugins/serendipity_event_entryproperties/lang_en.inc.php index 0b4cb83..116ef0a 100644 --- a/plugins/serendipity_event_entryproperties/lang_en.inc.php +++ b/plugins/serendipity_event_entryproperties/lang_en.inc.php @@ -37,4 +37,5 @@ @define('PLUGIN_EVENT_ENTRYPROPERTIES_CUSTOMFIELDS_DESC3', 'The list of available custom fields can be changed in the plugin configuration.'); @define('PLUGIN_EVENT_ENTRYPROPERTIES_DISABLE_MARKUP', 'Disable Markup plugins for this entry:'); -?> +@define('PLUGIN_EVENT_ENTRYPROPERTIES_EXTJOINS', 'Use extended database lookups'); +@define('PLUGIN_EVENT_ENTRYPROPERTIES_EXTJOINS_DESC', 'If enabled, additional SQL queries will be issued to be able to use sticky entries, hidden entries and removed entries from the frontpage. If those are not needed, disabling this feature can improve performance.'); diff --git a/plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php b/plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php index b28f404..4df1847 100644 --- a/plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php +++ b/plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php @@ -26,7 +26,7 @@ class serendipity_event_entryproperties extends serendipity_event $propbag->add('description', PLUGIN_EVENT_ENTRYPROPERTIES_DESC); $propbag->add('stackable', false); $propbag->add('author', 'Garvin Hicking'); - $propbag->add('version', '1.15'); + $propbag->add('version', '1.16'); $propbag->add('requirements', array( 'serendipity' => '0.8', 'smarty' => '2.6.7', @@ -53,7 +53,7 @@ class serendipity_event_entryproperties extends serendipity_event 'frontend_configure' => true )); $propbag->add('groups', array('BACKEND_EDITOR')); - $propbag->add('configuration', array('cache', 'use_groups', 'use_users', 'default_read', 'customfields')); + $propbag->add('configuration', array('cache', 'use_groups', 'use_users', 'use_ext_joins', 'default_read', 'customfields')); } function introspect_config_item($name, &$propbag) @@ -86,6 +86,13 @@ class serendipity_event_entryproperties extends serendipity_event $propbag->add('default', 'false'); break; + case 'use_ext_joins': + $propbag->add('type', 'boolean'); + $propbag->add('name', PLUGIN_EVENT_ENTRYPROPERTIES_EXTJOINS); + $propbag->add('description', PLUGIN_EVENT_ENTRYPROPERTIES_EXTJOINS_DESC); + $propbag->add('default', 'true'); + break; + case 'use_users': $propbag->add('type', 'boolean'); $propbag->add('name', PLUGIN_EVENT_ENTRYPROPERTIES_USERS); @@ -234,11 +241,19 @@ class serendipity_event_entryproperties extends serendipity_event function event_hook($event, &$bag, &$eventData, $addData = null) { global $serendipity; + static $is_cache = null; + static $use_groups = null; + static $use_users = null; + static $ext_joins = null; $hooks = &$bag->get('event_hooks'); - $is_cache = serendipity_db_bool($this->get_config('cache', 'true')); - $use_groups = serendipity_db_bool($this->get_config('use_groups')); - $use_users = serendipity_db_bool($this->get_config('use_users')); + + if ($is_cache === null) { + $is_cache = serendipity_db_bool($this->get_config('cache', 'true')); + $use_groups = serendipity_db_bool($this->get_config('use_groups')); + $use_users = serendipity_db_bool($this->get_config('use_users')); + $ext_joins = serendipity_db_bool($this->get_config('use_ext_joins')); + } if (isset($hooks[$event])) { switch($event) { @@ -665,6 +680,9 @@ class serendipity_event_entryproperties extends serendipity_event case 'frontend_fetchentry': $joins = array(); $conds = array(); + if (!$ext_joins) { + return true; + } if ($_SESSION['serendipityAuthedUser'] === true) { $conds[] = " (ep_access.property IS NULL OR ep_access.value = 'member' OR ep_access.value = 'public' OR (ep_access.value = 'private' AND e.authorid = " . (int)$serendipity['authorid'] . ")) ";