From: <var...@us...> - 2015-04-01 08:04:50
|
Revision: 9634 http://sourceforge.net/p/phpwiki/code/9634 Author: vargenau Date: 2015-04-01 08:04:48 +0000 (Wed, 01 Apr 2015) Log Message: ----------- Remove MockRequest Modified Paths: -------------- trunk/lib/MailNotify.php trunk/lib/WikiDB.php trunk/lib/loadsave.php trunk/lib/plugin/PasswordReset.php trunk/lib/plugin/UserPreferences.php trunk/lib/plugin/WatchPage.php Modified: trunk/lib/MailNotify.php =================================================================== --- trunk/lib/MailNotify.php 2015-03-31 13:37:40 UTC (rev 9633) +++ trunk/lib/MailNotify.php 2015-04-01 08:04:48 UTC (rev 9634) @@ -330,22 +330,15 @@ */ public function onChangePage(&$wikidb, &$wikitext, $version, &$meta) { - /** - * @var WikiRequest $request - */ - global $request; - - if (!is_a($request, 'MockRequest')) { - $notify = $wikidb->get('notify'); - /* Generate notification emails? */ - if (!empty($notify) and is_array($notify)) { - if (empty($this->pagename)) - $this->pagename = $meta['pagename']; - // TODO: Should be used for ModeratePage and RSS2 Cloud xml-rpc also. - $this->getPageChangeEmails($notify); - if (!empty($this->emails)) { - $this->sendPageChangeNotification($wikitext, $version, $meta); - } + $notify = $wikidb->get('notify'); + /* Generate notification emails? */ + if (!empty($notify) and is_array($notify)) { + if (empty($this->pagename)) + $this->pagename = $meta['pagename']; + // TODO: Should be used for ModeratePage and RSS2 Cloud xml-rpc also. + $this->getPageChangeEmails($notify); + if (!empty($this->emails)) { + $this->sendPageChangeNotification($wikitext, $version, $meta); } } } @@ -357,14 +350,9 @@ */ public function onDeletePage(&$wikidb, $pagename) { - /** - * @var WikiRequest $request - */ - global $request; - $result = true; /* Generate notification emails? */ - if (!$wikidb->isWikiPage($pagename) and !is_a($request, 'MockRequest')) { + if (!$wikidb->isWikiPage($pagename)) { $notify = $wikidb->get('notify'); if (!empty($notify) and is_array($notify)) { //TODO: deferr it (quite a massive load if you remove some pages). @@ -385,19 +373,12 @@ */ public function onRenamePage(&$wikidb, $oldpage, $new_pagename) { - /** - * @var WikiRequest $request - */ - global $request; - - if (!is_a($request, 'MockRequest')) { - $notify = $wikidb->get('notify'); - if (!empty($notify) and is_array($notify)) { - $this->getPageChangeEmails($notify); - if (!empty($this->emails)) { - $this->pagename = $oldpage; - $this->sendPageRenameNotification($new_pagename); - } + $notify = $wikidb->get('notify'); + if (!empty($notify) and is_array($notify)) { + $this->getPageChangeEmails($notify); + if (!empty($this->emails)) { + $this->pagename = $oldpage; + $this->sendPageRenameNotification($new_pagename); } } } Modified: trunk/lib/WikiDB.php =================================================================== --- trunk/lib/WikiDB.php 2015-03-31 13:37:40 UTC (rev 9633) +++ trunk/lib/WikiDB.php 2015-04-01 08:04:48 UTC (rev 9634) @@ -577,7 +577,7 @@ E_USER_WARNING); } /* Generate notification emails? */ - if ($result and ENABLE_MAILNOTIFY and !is_a($request, 'MockRequest')) { + if ($result and ENABLE_MAILNOTIFY) { $notify = $this->get('notify'); if (!empty($notify) and is_array($notify)) { include_once 'lib/MailNotify.php'; @@ -1083,7 +1083,6 @@ $notify = $this->_wikidb->get('notify'); if (!empty($notify) and is_array($notify) - and !is_a($request, 'MockRequest') ) { include_once 'lib/MailNotify.php'; $MailNotify = new MailNotify($newrevision->getName()); @@ -1697,7 +1696,7 @@ $this->getMetaData()); if ($possibly_cache_results and !WIKIDB_NOCACHE_MARKUP) { - // If we're still the current version, cache the transfomed page. + // If we're still the current version, cache the transformed page. //$backend->lock(); if ($this->isCurrent()) { $page->set('_cached_html', $this->_transformedContent->pack()); Modified: trunk/lib/loadsave.php =================================================================== --- trunk/lib/loadsave.php 2015-03-31 13:37:40 UTC (rev 9633) +++ trunk/lib/loadsave.php 2015-04-01 08:04:48 UTC (rev 9634) @@ -37,12 +37,14 @@ return true; // Ignore error } -function StartLoadDump(&$request, $title, $html = '') +/** + * @param WikiRequest $request + * @param string $title + * @param HTML $html + */ + +function StartLoadDump(&$request, $title, $html = null) { - // MockRequest is from the unit testsuite, a faked request. (may be cmd-line) - // We are silent on unittests. - if (is_a($request, 'MockRequest')) - return; // FIXME: This is a hack. This really is the worst overall hack in phpwiki. if ($html) $html->pushContent('%BODY%'); @@ -56,12 +58,13 @@ $request->_deferredPageChangeNotification = array(); } +/** + * @param WikiRequest $request + */ function EndLoadDump(&$request) { global $WikiTheme; - if (is_a($request, 'MockRequest')) - return; $action = $request->getArg('action'); if ($action == 'browse') // loading virgin $pagelink = WikiLink(HOME_PAGE); @@ -140,6 +143,10 @@ * (RFC 1521 has been superceeded by RFC 2045 & others). * * Also see http://www.faqs.org/rfcs/rfc2822.html +/* + * @param WikiDB_Page $page + * @param int $nversions + * @return string */ function MailifyPage($page, $nversions = 1) { @@ -215,6 +222,8 @@ * If $include_archive is false, only the current version of each page * is included in the zip file; otherwise all archived versions are * included as well. + * + * @param WikiRequest $request */ function MakeWikiZip(&$request) { @@ -304,6 +313,9 @@ exit; } +/** + * @param WikiRequest $request + */ function DumpToDir(&$request) { $directory = $request->getArg('directory'); @@ -352,16 +364,12 @@ longer_timeout($timeout); // Reset watchdog $pagename = $page->getName(); - if (!is_a($request, 'MockRequest')) { - PrintXML(HTML::br(), $pagename, ' ... '); - flush(); - } + PrintXML(HTML::br(), $pagename, ' ... '); + flush(); if (in_array($pagename, $excludeList)) { - if (!is_a($request, 'MockRequest')) { - PrintXML(_("Skipped.")); - flush(); - } + PrintXML(_("Skipped.")); + flush(); continue; } $filename = FilenameForPage($pagename); @@ -384,10 +392,8 @@ $num = fwrite($fd, $data, strlen($data)); $msg->pushContent(HTML::small(fmt("%s bytes written", $num))); - if (!is_a($request, 'MockRequest')) { - PrintXML($msg); - flush(); - } + PrintXML($msg); + flush(); assert($num == strlen($data)); fclose($fd); } @@ -397,12 +403,10 @@ function _copyMsg($page, $smallmsg) { - if (!is_a($GLOBALS['request'], 'MockRequest')) { - if ($page) $msg = HTML(HTML::br(), HTML($page), HTML::small($smallmsg)); - else $msg = HTML::small($smallmsg); - PrintXML($msg); - flush(); - } + if ($page) $msg = HTML(HTML::br(), HTML($page), HTML::small($smallmsg)); + else $msg = HTML::small($smallmsg); + PrintXML($msg); + flush(); } function mkdir_p($pathname, $permission = 0777) @@ -485,7 +489,8 @@ EndLoadDump($request); } -/* Known problem: any plugins or other code which echo()s text will +/** + * Known problem: any plugins or other code which echo()s text will * lead to a corrupted html zip file which may produce the following * errors upon unzipping: * @@ -494,7 +499,10 @@ * (attempting to re-compensate) * * However, the actual wiki page data should be unaffected. + * + * @param WikiRequest $request */ + function MakeWikiZipHtml(&$request) { global $WikiTheme; @@ -634,13 +642,11 @@ if ($page->get('locked')) $attrib['write_protected'] = 1; } elseif (!$silent) { - if (!is_a($request, 'MockRequest')) { - PrintXML(HTML::br(), $pagename, ' ... '); - flush(); - } + PrintXML(HTML::br(), $pagename, ' ... '); + flush(); } if (in_array($pagename, $excludeList)) { - if (!$silent and !is_a($request, 'MockRequest')) { + if (!$silent) { PrintXML(_("Skipped.")); flush(); } @@ -723,9 +729,7 @@ } $msg->pushContent(HTML::small(fmt("%s bytes written", $num), "\n")); if (!$silent) { - if (!is_a($request, 'MockRequest')) { - PrintXML($msg); - } + PrintXML($msg); flush(); $request->chunkOutput(); } @@ -1019,10 +1023,8 @@ if (!$skip) { // in case of failures print the culprit: - if (!is_a($request, 'MockRequest')) { - PrintXML(HTML::span(WikiLink($pagename))); - flush(); - } + PrintXML(HTML::span(WikiLink($pagename))); + flush(); $new = $page->save($content, WIKIDB_FORCE_CREATE, $versiondata); $dbi->touch(); $mesg->pushContent(' ', fmt("- saved to database as version %d", @@ -1065,13 +1067,11 @@ } } - if (!is_a($request, 'MockRequest')) { - if ($skip) - PrintXML(HTML::em(WikiLink($pagename)), $mesg); - else - PrintXML($mesg); - flush(); - } + if ($skip) + PrintXML(HTML::em(WikiLink($pagename)), $mesg); + else + PrintXML($mesg); + flush(); } // action=revert (by diff) @@ -1169,9 +1169,7 @@ if ($goback) return $content; - // if loading from virgin setup do echo, otherwise trigger_error E_USER_NOTICE - if (!is_a($GLOBALS['request'], 'MockRequest')) - echo sprintf(_("Loading InterWikiMap from external file %s."), $mapfile), "<br />"; + echo sprintf(_("Loading InterWikiMap from external file %s."), $mapfile), "<br />"; $fd = fopen($mapfile, "rb"); $data = fread($fd, filesize($mapfile)); @@ -1420,6 +1418,12 @@ return $magic == ZIP_LOCHEAD_MAGIC || $magic == ZIP_CENTHEAD_MAGIC; } +/** + * @param WikiRequest $request + * @param string $file_or_dir + * @param array $files + * @param array $exclude + */ function LoadAny(&$request, $file_or_dir, $files = array(), $exclude = array()) { // Try urlencoded filename for accented characters. @@ -1464,13 +1468,15 @@ } } +/** + * @param WikiRequest $request + */ function LoadFileOrDir(&$request) { $source = $request->getArg('source'); $finder = new FileFinder; $source = $finder->slashifyPath($source); - StartLoadDump($request, - sprintf(_("Loading “%s”"), $source)); + StartLoadDump($request, sprintf(_("Loading “%s”"), $source)); LoadAny($request, $source); EndLoadDump($request); } @@ -1479,6 +1485,8 @@ * HomePage was not found so first-time install is supposed to run. * - import all pgsrc pages. * - Todo: installer interface to edit config/config.ini settings + * + * @param WikiRequest $request */ function SetupWiki(&$request) { Modified: trunk/lib/plugin/PasswordReset.php =================================================================== --- trunk/lib/plugin/PasswordReset.php 2015-03-31 13:37:40 UTC (rev 9633) +++ trunk/lib/plugin/PasswordReset.php 2015-04-01 08:04:48 UTC (rev 9634) @@ -65,6 +65,10 @@ $alert->show(); } + /** + * @param WikiRequest $request + * @param string $userid + */ private function doEmail(&$request, $userid) { @@ -87,6 +91,13 @@ $alert->show(); } + /** + * @param WikiRequest $request + * @param string $userid + * @param string $header + * @param string $footer + * @return HtmlElement + */ private function doForm(&$request, $userid = '', $header = '', $footer = '') { if (!$header) { @@ -123,9 +134,6 @@ function run($dbi, $argstr, &$request, $basepage) { $args = $this->getArgs($argstr, $request); - if (is_a($request, 'MockRequest')) - return ''; - $user =& $request->_user; $post_args = $request->getArg('admin_reset'); $userid = $args['user']; Modified: trunk/lib/plugin/UserPreferences.php =================================================================== --- trunk/lib/plugin/UserPreferences.php 2015-03-31 13:37:40 UTC (rev 9633) +++ trunk/lib/plugin/UserPreferences.php 2015-04-01 08:04:48 UTC (rev 9634) @@ -73,8 +73,6 @@ $args = $this->getArgs($argstr, $request); $user =& $request->_user; $user->_request = $request; - if (is_a($request, 'MockRequest')) - return ''; if (defined('FUSIONFORGE') && FUSIONFORGE) { if (!($user->isAuthenticated())) { return HTML::p(array('class' => 'error'), Modified: trunk/lib/plugin/WatchPage.php =================================================================== --- trunk/lib/plugin/WatchPage.php 2015-03-31 13:37:40 UTC (rev 9633) +++ trunk/lib/plugin/WatchPage.php 2015-04-01 08:04:48 UTC (rev 9634) @@ -104,10 +104,7 @@ */ function run($dbi, $argstr, &$request, $basepage) { - $args = $this->getArgs($argstr, $request); - if (is_a($request, 'MockRequest')) - return ''; $user =& $request->_user; $userid = $user->UserName(); $page = $args['page']; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |