]> git.wh0rd.org - tt-rss.git/commitdiff
perform housekeeping tasks for plugins loaded in user-context only
authorAndrew Dolgov <noreply@madoka.volgo-balt.ru>
Thu, 11 Aug 2016 12:01:01 +0000 (15:01 +0300)
committerAndrew Dolgov <noreply@madoka.volgo-balt.ru>
Thu, 11 Aug 2016 12:01:01 +0000 (15:01 +0300)
include/functions.php
include/rssfuncs.php

index 3ccc09d751d8474748794477beecd9a495843990..3902ac45a347aa2aa606a54811371b3bfc8fd6dc 100755 (executable)
                return $csrf_token == $_SESSION['csrf_token'];
        }
 
-       function load_user_plugins($owner_uid) {
+       function load_user_plugins($owner_uid, $pluginhost = false) {
+
+               if (!$pluginhost) $pluginhost = PluginHost::getInstance();
+
                if ($owner_uid && SCHEMA_VERSION >= 100) {
                        $plugins = get_pref("_ENABLED_PLUGINS", $owner_uid);
 
-                       PluginHost::getInstance()->load($plugins, PluginHost::KIND_USER, $owner_uid);
+                       $pluginhost->load($plugins, PluginHost::KIND_USER, $owner_uid);
 
                        if (get_schema_version() > 100) {
-                               PluginHost::getInstance()->load_data();
+                               $pluginhost->load_data();
                        }
                }
        }
index 522e4bf2298458bc7b3e50e11106998b798572cd..cbd011e5c351a7c457969e3db7d460dcafa63917 100644 (file)
                $nf = 0;
                $bstarted = microtime(true);
 
+               $batch_owners = array();
+
                // For each feed, we call the feed update function.
                foreach ($feeds_to_update as $feed) {
                        if($debug) _debug("Base feed: $feed");
                                while ($tline = db_fetch_assoc($tmp_result)) {
                                        if($debug) _debug(" => " . $tline["last_updated"] . ", " . $tline["id"] . " " . $tline["owner_uid"]);
 
+                                       if (array_search($tline["owner_uid"], $batch_owners) === FALSE)
+                                               array_push($batch_owners, $tline["owner_uid"]);
+
                                        $fstarted = microtime(true);
                                        $rss = update_rss_feed($tline["id"], true, false);
                                        _debug_suppress(false);
                                microtime(true) - $bstarted, (microtime(true) - $bstarted) / $nf));
                }
 
+               foreach ($batch_owners as $owner_uid) {
+                       _debug("Running housekeeping tasks for user $owner_uid...");
+
+                       housekeeping_user($owner_uid);
+               }
+
                require_once "digest.php";
 
                // Send feed digests by email if needed.
                _debug("Removed $frows (feeds) $crows (cats) orphaned counter cache entries.");
        }
 
+       function housekeeping_user($owner_uid) {
+               $tmph = new PluginHost();
+
+               load_user_plugins($owner_uid, $tmph);
+
+               $tmph->run_hooks(PluginHost::HOOK_HOUSE_KEEPING, "hook_house_keeping", "");
+       }
+
        function housekeeping_common($debug) {
                expire_cached_files($debug);
                expire_lock_files($debug);
                //_debug("Cleaned $rc cached tags.");
 
                PluginHost::getInstance()->run_hooks(PluginHost::HOOK_HOUSE_KEEPING, "hook_house_keeping", "");
-
        }
 ?>