advise_before()) { $this->runIndexer() or $this->runSitemapper() or $this->sendDigest() or $this->runTrimRecentChanges() or $this->runTrimRecentChanges(true) or $evt->advise_after(); } } /** * Trims the recent changes cache (or imports the old changelog) as needed. * * @param bool $media_changes If the media changelog shall be trimmed instead of * the page changelog * @return bool * * @author Ben Coburn */ protected function runTrimRecentChanges($media_changes = false) { global $conf; echo "runTrimRecentChanges($media_changes): started".NL; $fn = ($media_changes ? $conf['media_changelog'] : $conf['changelog']); // Trim the Recent Changes // Trims the recent changes cache to the last $conf['changes_days'] recent // changes or $conf['recent'] items, which ever is larger. // The trimming is only done once a day. if (file_exists($fn) && (@filemtime($fn.'.trimmed')+86400) 0) { ksort($old_lines); $out_lines = array_merge(array_slice($old_lines,-$extra),$out_lines); } // save trimmed changelog io_saveFile($fn.'_tmp', implode('', $out_lines)); @unlink($fn); if (!rename($fn.'_tmp', $fn)) { // rename failed so try another way... io_unlock($fn); io_saveFile($fn, implode('', $out_lines)); @unlink($fn.'_tmp'); } else { io_unlock($fn); } echo "runTrimRecentChanges($media_changes): finished".NL; return true; } // nothing done echo "runTrimRecentChanges($media_changes): finished".NL; return false; } /** * Runs the indexer for the current page * * @author Andreas Gohr */ protected function runIndexer(){ global $ID; global $conf; print "runIndexer(): started".NL; if(!$ID) return false; // do the work return idx_addPage($ID, true); } /** * Builds a Google Sitemap of all public pages known to the indexer * * The map is placed in the root directory named sitemap.xml.gz - This * file needs to be writable! * * @author Andreas Gohr * @link https://www.google.com/webmasters/sitemaps/docs/en/about.html */ protected function runSitemapper(){ print "runSitemapper(): started".NL; $result = Sitemapper::generate() && Sitemapper::pingSearchEngines(); print 'runSitemapper(): finished'.NL; return $result; } /** * Send digest and list mails for all subscriptions which are in effect for the * current page * * @author Adrian Lang */ protected function sendDigest() { global $conf; global $ID; echo 'sendDigest(): started'.NL; if(!actionOK('subscribe')) { echo 'sendDigest(): disabled'.NL; return false; } $sub = new Subscription(); $sent = $sub->send_bulk($ID); echo "sendDigest(): sent $sent mails".NL; echo 'sendDigest(): finished'.NL; return (bool) $sent; } }