]> git.wh0rd.org - tt-rss.git/blobdiff - include/rssfuncs.php
better debugging for matched filter rules
[tt-rss.git] / include / rssfuncs.php
index 522e4bf2298458bc7b3e50e11106998b798572cd..32bc69819bf8a0fa0e059aa5044ca625403f2ed1 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.
 
                                /* Collect article tags here so we could filter by them: */
 
+                               $matched_rules = array();
+
                                $article_filters = get_article_filters($filters, $article["title"],
                                        $article["content"], $article["link"], 0, $article["author"],
-                                       $article["tags"]);
+                                       $article["tags"], $matched_rules);
 
                                if ($debug_enabled) {
-                                       _debug("article filters: ", $debug_enabled);
+                                       _debug("matched filter rules: ", $debug_enabled);
+
+                                       if (count($matched_rules) != 0) {
+                                               print_r($matched_rules);
+                                       }
+
+                                       _debug("filter actions: ", $debug_enabled);
+
                                        if (count($article_filters) != 0) {
                                                print_r($article_filters);
                                        }
 
                                if ($debug_enabled) {
                                        _debug("article labels:", $debug_enabled);
-                                       print_r($article_labels);
+
+                                       if (count($article_labels) != 0) {
+                                               print_r($article_labels);
+                                       }
                                }
 
                                _debug("force catchup: $entry_force_catchup");
                return $params;
        }
 
-       function get_article_filters($filters, $title, $content, $link, $timestamp, $author, $tags) {
+       function get_article_filters($filters, $title, $content, $link, $timestamp, $author, $tags, &$matched_rules = false) {
                $matches = array();
 
                foreach ($filters as $filter) {
                        if ($inverse) $filter_match = !$filter_match;
 
                        if ($filter_match) {
+                               if (is_array($matched_rules)) array_push($matched_rules, $rule);
+
                                foreach ($filter["actions"] AS $action) {
                                        array_push($matches, $action);
 
                _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", "");
-
        }
 ?>