/** * main entry point * * @access public */ public function run() { global $wgUseEnotif; wfProfileIn(__METHOD__); if (!$wgUseEnotif) { wfProfileOut(__METHOD__); return true; } if ($this->mParams['user_id']) { /* registered User */ $editor = User::newFromID($this->mParams['user_id']); } elseif ($this->mParams['user_name']) { /* anons */ $editor = User::newFromName($this->mParams['user_name'], false); } else { /* invalid user */ wfProfileOut(__METHOD__); return true; } /** * get title of page, take main part from this title which will be * main page for user blogs (listing) */ $ownerTitle = BlogArticle::getOwnerTitle($this->title); /** * check who watches this page */ $dbr = wfGetDB(DB_SLAVE); $res = $dbr->select(array("watchlist"), array("wl_user"), array("wl_namespace" => $ownerTitle->getNamespace(), "wl_title" => $ownerTitle->getDBKey()), __METHOD__); while ($row = $dbr->fetchObject($res)) { $watchers[] = intval($row->wl_user); } if (!empty($watchers)) { $enotif = new EmailNotification(); $title = Title::makeTitle($ownerTitle->getNamespace(), $ownerTitle->getDBKey()); $enotif->actuallyNotifyOnPageChange($editor, $title, $this->params['timestamp'], $this->params['comment'], $this->params['minor'], 0, $watchers, $this->params['log_action']); /* Update wl_notificationtimestamp for all watching users except the editor */ $dbw = wfGetDB(DB_MASTER); $dbw->begin(); $dbw->update('watchlist', array('wl_notificationtimestamp' => $dbw->timestamp(wfTimestampNow())), array('wl_title' => $ownerTitle->getDBkey(), 'wl_namespace' => $ownerTitle->getNamespace(), 'wl_user' => $watchers), __METHOD__); $dbw->commit(); } wfProfileOut(__METHOD__); return true; }
} else { error_log("Can't find command line include file '{$bootstrap_file}'"); } print "done\n"; $article_id = $argv[0]; $title = Title::newFromID($article_id); if (!$title instanceof Title) { die("Could not make new comment from article ID '{$article_id}'"); } createComment($title, $argv[1], $argv[2]); /** * clear comments cache for this article */ $title->invalidateCache(); $title->purgeSquid(); $listing = BlogArticle::getOwnerTitle($title); if ($listing) { $listing->invalidateCache(); $listing->purgeSquid(); } $key = $title->getPrefixedDBkey(); $wgMemc->delete(wfMemcKey("blog", "listing", $key, 0)); $clist = BlogCommentList::newFromTitle($title); $clist->getCommentPages(true); function createComment($title = null, $commenter = null, $text = null) { global $wgTitle; $text = $text ? $text : 'The quick brown fox jumps over the lazy dog'; $commentTitle = Title::newFromText(sprintf("%s/%s-%s", $title->getText(), $commenter, wfTimestampNow()), NS_BLOG_ARTICLE_TALK); $wgTitle = $commentTitle; /**