]> git.mjollnir.org Git - s9y.git/commitdiff
Add option to speed up joining when not needed
authorgarvinhicking <garvinhicking>
Sat, 8 Mar 2008 10:27:17 +0000 (10:27 +0000)
committergarvinhicking <garvinhicking>
Sat, 8 Mar 2008 10:27:17 +0000 (10:27 +0000)
plugins/serendipity_event_entryproperties/lang_en.inc.php
plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php

index 0b4cb834ca2225fa10f522f2e0280f6c96bb21d3..116ef0a5e638475954c1b232728d714128da6fdc 100644 (file)
@@ -37,4 +37,5 @@
 @define('PLUGIN_EVENT_ENTRYPROPERTIES_CUSTOMFIELDS_DESC3', 'The list of available custom fields can be changed in the <a href="%s" target="_blank" title="' . PLUGIN_EVENT_ENTRYPROPERTIES_TITLE . '">plugin configuration</a>.');
 
 @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.');
index b28f40463f417c7804f15735b8bd30ef690fd98b..4df1847a9d2ce2a9d0a18bc607244c5f4cd3630d 100644 (file)
@@ -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'] . ")) ";