summaryrefslogtreecommitdiff
path: root/classes/rssutils.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2019-11-14 06:39:45 +0300
committerAndrew Dolgov <[email protected]>2019-11-14 06:39:45 +0300
commit0d7b10469bbd1e0923fd044283ab9948fb887e57 (patch)
tree255a75505de6b7ce8541c19cb6e9a305928f782b /classes/rssutils.php
parent762ff9b9cd56edbb0a96742b26c47bead1d79625 (diff)
update_rss_feed: add specific logging for HOOK_FETCH_FEED, HOOK_FEED_FETCHED, HOOK_FEED_PARSED handlers
Diffstat (limited to 'classes/rssutils.php')
-rwxr-xr-xclasses/rssutils.php33
1 files changed, 32 insertions, 1 deletions
diff --git a/classes/rssutils.php b/classes/rssutils.php
index 1904176f8..bff4bd9fc 100755
--- a/classes/rssutils.php
+++ b/classes/rssutils.php
@@ -335,8 +335,19 @@ class RSSUtils {
$force_refetch = isset($_REQUEST["force_refetch"]);
$feed_data = "";
+ Debug::log("running HOOK_FETCH_FEED handlers...", Debug::$LOG_VERBOSE);
+
foreach ($pluginhost->get_hooks(PluginHost::HOOK_FETCH_FEED) as $plugin) {
+ Debug::log("... " . get_class($plugin), Debug::$LOG_VERBOSE);
+ $start = microtime(true);
$feed_data = $plugin->hook_fetch_feed($feed_data, $fetch_url, $owner_uid, $feed, 0, $auth_login, $auth_pass);
+ Debug::log(sprintf("=== %.4f (sec)", microtime(true) - $start), Debug::$LOG_VERBOSE);
+ }
+
+ if ($feed_data) {
+ Debug::log("feed data has been modified by a plugin.", Debug::$LOG_VERBOSE);
+ } else {
+ Debug::log("feed data has not been modified by a plugin.", Debug::$LOG_VERBOSE);
}
// try cache
@@ -428,8 +439,20 @@ class RSSUtils {
return;
}
+ Debug::log("running HOOK_FEED_FETCHED handlers...", Debug::$LOG_VERBOSE);
+ $feed_data_checksum = md5($feed_data);
+
foreach ($pluginhost->get_hooks(PluginHost::HOOK_FEED_FETCHED) as $plugin) {
+ Debug::log("... " . get_class($plugin), Debug::$LOG_VERBOSE);
+ $start = microtime(true);
$feed_data = $plugin->hook_feed_fetched($feed_data, $fetch_url, $owner_uid, $feed);
+ Debug::log(sprintf("=== %.4f (sec)", microtime(true) - $start), Debug::$LOG_VERBOSE);
+ }
+
+ if (md5($feed_data) != $feed_data_checksum) {
+ Debug::log("feed data has been modified by a plugin.", Debug::$LOG_VERBOSE);
+ } else {
+ Debug::log("feed data has not been modified by a plugin.", Debug::$LOG_VERBOSE);
}
$rss = new FeedParser($feed_data);
@@ -437,8 +460,16 @@ class RSSUtils {
if (!$rss->error()) {
+ Debug::log("running HOOK_FEED_PARSED handlers...", Debug::$LOG_VERBOSE);
+
// We use local pluginhost here because we need to load different per-user feed plugins
- $pluginhost->run_hooks(PluginHost::HOOK_FEED_PARSED, "hook_feed_parsed", $rss);
+
+ foreach ($pluginhost->get_hooks(PluginHost::HOOK_FEED_PARSED) as $plugin) {
+ Debug::log("... " . get_class($plugin), Debug::$LOG_VERBOSE);
+ $start = microtime(true);
+ $plugin->hook_feed_parsed($rss);
+ Debug::log(sprintf("=== %.4f (sec)", microtime(true) - $start), Debug::$LOG_VERBOSE);
+ }
Debug::log("language: $feed_language", Debug::$LOG_VERBOSE);
Debug::log("processing feed data...", Debug::$LOG_VERBOSE);