Пример #1
0
 /**
  * Switch this module to generator mode. By default, generator mode is
  * switched off and the module acts like a normal query module.
  * @since 1.21 requires pageset parameter
  * @param ApiPageSet $generatorPageSet ApiPageSet object that the module will get
  *        by calling getPageSet() when in generator mode.
  */
 public function setGeneratorMode(ApiPageSet $generatorPageSet)
 {
     if ($generatorPageSet === null) {
         ApiBase::dieDebug(__METHOD__, 'Required parameter missing - $generatorPageSet');
     }
     $this->mGeneratorPageSet = $generatorPageSet;
 }
Пример #2
0
 public function execute()
 {
     global $wgUser;
     $this->checkPermission($wgUser);
     $params = $this->extractRequestParams();
     $res = array();
     $concurrencyCheck = new ConcurrencyCheck($params['resourcetype'], $wgUser);
     switch ($params['ccaction']) {
         case 'checkout':
         case 'checkin':
             if ($concurrencyCheck->{$params}['ccaction']($params['record'])) {
                 $res['result'] = 'success';
             } else {
                 $res['result'] = 'failure';
             }
             // data to be utilized by the caller for checkout
             if ($params['ccaction'] === 'checkout') {
                 $lastCheckout = $concurrencyCheck->checkoutResult();
                 if ($res['result'] === 'success') {
                     $user = $wgUser;
                 } else {
                     $user = User::newFromId(intval($lastCheckout['userId']));
                 }
                 if (!$user->isAnon()) {
                     $res['userid'] = $user->getId();
                     $res['username'] = $user->getName();
                 }
                 $res['expiration'] = $lastCheckout['expiration'];
             }
             break;
         default:
             ApiBase::dieDebug(__METHOD__, "Unhandled concurrency action: {$params['ccaction']}");
     }
     $this->getResult()->addValue(null, $this->getModuleName(), $res);
 }
Пример #3
0
 public function execute()
 {
     $prop = null;
     extract($this->extractRequestParams());
     foreach ($prop as $p) {
         switch ($p) {
             case 'general':
                 global $wgSitename, $wgVersion, $wgCapitalLinks;
                 $data = array();
                 $mainPage = Title::newFromText(wfMsgForContent('mainpage'));
                 $data['mainpage'] = $mainPage->getText();
                 $data['base'] = $mainPage->getFullUrl();
                 $data['sitename'] = $wgSitename;
                 $data['generator'] = "MediaWiki {$wgVersion}";
                 $data['case'] = $wgCapitalLinks ? 'first-letter' : 'case-sensitive';
                 // 'case-insensitive' option is reserved for future
                 $this->getResult()->addValue('query', $p, $data);
                 break;
             case 'namespaces':
                 global $wgContLang;
                 $data = array();
                 foreach ($wgContLang->getFormattedNamespaces() as $ns => $title) {
                     $data[$ns] = array('id' => $ns);
                     ApiResult::setContent($data[$ns], $title);
                 }
                 ApiResult::setIndexedTagName($data, 'ns');
                 $this->getResult()->addValue('query', $p, $data);
                 break;
             default:
                 ApiBase::dieDebug(__METHOD__, "Unknown prop={$p}");
         }
     }
 }
Пример #4
0
 protected function getDescriptionMessage()
 {
     if (!$this->hasAnyRoutes()) {
         return 'apihelp-resetpassword-description-noroutes';
     }
     return parent::getDescriptionMessage();
 }
Пример #5
0
 public function __construct(ApiMain $main, $name, Config $config)
 {
     parent::__construct($main, $name);
     $this->veConfig = $config;
     $this->serviceClient = new VirtualRESTServiceClient(new MultiHttpClient(array()));
     $this->serviceClient->mount('/restbase/', $this->getVRSObject());
 }
Пример #6
0
 public function getFinalDescription()
 {
     // A bit of a hack to append 'api-help-authmanager-general-usage'
     $msgs = parent::getFinalDescription();
     $msgs[] = ApiBase::makeMessage('api-help-authmanager-general-usage', $this->getContext(), [$this->getModulePrefix(), $this->getModuleName(), $this->getModulePath(), AuthManager::ACTION_LOGIN, self::needsToken()]);
     return $msgs;
 }
 public function __construct($query, $moduleName)
 {
     switch ($moduleName) {
         case 'alllinks':
             $prefix = 'al';
             $this->table = 'pagelinks';
             $this->tablePrefix = 'pl_';
             $this->dfltNamespace = NS_MAIN;
             $this->indexTag = 'l';
             $this->description = 'Enumerate all links that point to a given namespace';
             $this->descriptionLink = 'link';
             $this->descriptionLinked = 'linked';
             $this->descriptionLinking = 'linking';
             break;
         case 'alltransclusions':
             $prefix = 'at';
             $this->table = 'templatelinks';
             $this->tablePrefix = 'tl_';
             $this->dfltNamespace = NS_TEMPLATE;
             $this->indexTag = 't';
             $this->description = 'List all transclusions (pages embedded using {{x}}), including non-existing';
             $this->descriptionLink = 'transclusion';
             $this->descriptionLinked = 'transcluded';
             $this->descriptionLinking = 'transcluding';
             break;
         default:
             ApiBase::dieDebug(__METHOD__, 'Unknown module name');
     }
     parent::__construct($query, $moduleName, $prefix);
 }
 private function run($resultPageSet = null)
 {
     if ($this->getPageSet()->getGoodTitleCount() == 0) {
         return;
     }
     // nothing to do
     $params = $this->extractRequestParams();
     $prop = $params['prop'];
     $this->addFields(array('cl_from', 'cl_to'));
     $fld_sortkey = false;
     if (!is_null($prop)) {
         foreach ($prop as $p) {
             switch ($p) {
                 case 'sortkey':
                     $this->addFields('cl_sortkey');
                     $fld_sortkey = true;
                     break;
                 default:
                     ApiBase::dieDebug(__METHOD__, "Unknown prop={$p}");
             }
         }
     }
     $this->addTables('categorylinks');
     $this->addWhereFld('cl_from', array_keys($this->getPageSet()->getGoodTitles()));
     $this->addOption('ORDER BY', "cl_from, cl_to");
     $db = $this->getDB();
     $res = $this->select(__METHOD__);
     if (is_null($resultPageSet)) {
         $data = array();
         $lastId = 0;
         // database has no ID 0
         while ($row = $db->fetchObject($res)) {
             if ($lastId != $row->cl_from) {
                 if ($lastId != 0) {
                     $this->addPageSubItems($lastId, $data);
                     $data = array();
                 }
                 $lastId = $row->cl_from;
             }
             $title = Title::makeTitle(NS_CATEGORY, $row->cl_to);
             $vals = array();
             ApiQueryBase::addTitleInfo($vals, $title);
             if ($fld_sortkey) {
                 $vals['sortkey'] = $row->cl_sortkey;
             }
             $data[] = $vals;
         }
         if ($lastId != 0) {
             $this->addPageSubItems($lastId, $data);
         }
     } else {
         $titles = array();
         while ($row = $db->fetchObject($res)) {
             $titles[] = Title::makeTitle(NS_CATEGORY, $row->cl_to);
         }
         $resultPageSet->populateFromTitles($titles);
     }
     $db->freeResult($res);
 }
 public function __construct(ApiMain $main, $name)
 {
     global $wgContentTranslationParsoid;
     parent::__construct($main, $name);
     $this->serviceClient = new VirtualRESTServiceClient(new MultiHttpClient(array()));
     $parsoidConfig = $wgContentTranslationParsoid;
     $this->serviceClient->mount('/parsoid/', new ParsoidVirtualRESTService(array('URL' => $parsoidConfig['url'], 'prefix' => $parsoidConfig['prefix'], 'timeout' => $parsoidConfig['timeout'])));
 }
Пример #10
0
 /**
  * @return string
  */
 public function makeHelpMsg()
 {
     $msg = parent::makeHelpMsg();
     $querySeparator = str_repeat('--- ', 12);
     $moduleSeparator = str_repeat('*** ', 14);
     $msg .= "\n{$querySeparator} Analytics: Metrics  {$querySeparator}\n\n";
     global $wgMetricAPIModules;
     $msg .= $this->makeHelpMsgHelper($wgMetricAPIModules, 'metric');
     $msg .= "\n\n{$moduleSeparator} Modules: continuation  {$moduleSeparator}\n\n";
     return $msg;
 }
Пример #11
0
 /**
  * Constructor
  */
 public function __construct($main, $format)
 {
     parent::__construct($main, $format);
     $this->mIsHtml = substr($format, -2, 2) === 'fm';
     // ends with 'fm'
     if ($this->mIsHtml) {
         $this->mFormat = substr($format, 0, -2);
     } else {
         $this->mFormat = $format;
     }
     $this->mFormat = strtoupper($this->mFormat);
 }
Пример #12
0
 public function execute()
 {
     $data = $this->getResultData();
     if (isset($data['error'])) {
         $this->mErrorFallback->execute();
         return;
     }
     if (!isset($data['text'])) {
         ApiBase::dieDebug(__METHOD__, 'No text given for raw formatter');
     }
     $this->printText($data['text']);
 }
Пример #13
0
 /**
  * If $format ends with 'fm', pretty-print the output in HTML.
  * @param ApiMain $main
  * @param string $format Format name
  */
 public function __construct(ApiMain $main, $format)
 {
     parent::__construct($main, $format);
     $this->mIsHtml = substr($format, -2, 2) === 'fm';
     // ends with 'fm'
     if ($this->mIsHtml) {
         $this->mFormat = substr($format, 0, -2);
         // remove ending 'fm'
     } else {
         $this->mFormat = $format;
     }
     $this->mFormat = strtoupper($this->mFormat);
     $this->mCleared = false;
 }
Пример #14
0
 protected function addTables($tables, $alias = null)
 {
     if (is_array($tables)) {
         if (!is_null($alias)) {
             ApiBase::dieDebug(__METHOD__, 'Multiple table aliases not supported');
         }
         $this->tables = array_merge($this->tables, $tables);
     } else {
         if (!is_null($alias)) {
             $tables = $this->getDB()->tableName($tables) . ' ' . $alias;
         }
         $this->tables[] = $tables;
     }
 }
Пример #15
0
 public function execute()
 {
     $data = $this->getResult()->getResultData();
     if (isset($data['error'])) {
         $this->errorFallback->execute();
         return;
     }
     if (isset($data['file'])) {
         $this->file = $data['file'];
     } elseif (isset($data['text'])) {
         $this->printText($data['text']);
     } else {
         ApiBase::dieDebug(__METHOD__, 'No text or file given for file formatter');
     }
 }
Пример #16
0
 public function __construct($query, $moduleName)
 {
     switch ($moduleName) {
         case self::LINKS:
             $this->table = 'pagelinks';
             $this->prefix = 'pl';
             $this->description = 'link';
             break;
         case self::TEMPLATES:
             $this->table = 'templatelinks';
             $this->prefix = 'tl';
             $this->description = 'template';
             break;
         default:
             ApiBase::dieDebug(__METHOD__, 'Unknown module name');
     }
     parent::__construct($query, $moduleName, $this->prefix);
 }
Пример #17
0
 public function __construct(ApiQuery $query, $moduleName)
 {
     switch ($moduleName) {
         case self::LINKS:
             $this->table = 'pagelinks';
             $this->prefix = 'pl';
             $this->titlesParam = 'titles';
             $this->helpUrl = 'https://www.mediawiki.org/wiki/API:Links';
             break;
         case self::TEMPLATES:
             $this->table = 'templatelinks';
             $this->prefix = 'tl';
             $this->titlesParam = 'templates';
             $this->helpUrl = 'https://www.mediawiki.org/wiki/API:Templates';
             break;
         default:
             ApiBase::dieDebug(__METHOD__, 'Unknown module name');
     }
     parent::__construct($query, $moduleName, $this->prefix);
 }
Пример #18
0
 public function Execute($method = null)
 {
     if ($method == null) {
         $method = UrlUtils::RequestMethod();
         if (UrlUtils::ExistRequestParam("method")) {
             $method = strtolower(UrlUtils::GetRequestParam("method"));
         }
     }
     $availableMethods = get_class_methods(get_class($this));
     $function = "do" . $method;
     try {
         if (in_array($function, $availableMethods)) {
             $this->{$function}();
         } else {
             ApiBase::ReturnError("Invalid method", 405);
         }
     } catch (Exception $ex) {
         ApiBase::ReturnError($ex->getMessage(), 500);
     }
 }
 public function execute()
 {
     global $wgUser;
     $this->checkPermission($wgUser);
     $params = $this->extractRequestParams();
     $res = array();
     $concurrencyCheck = new ConcurrencyCheck($params['resourcetype'], $wgUser);
     switch ($params['ccaction']) {
         case 'checkout':
         case 'checkin':
             if ($concurrencyCheck->{$params}['ccaction']($params['record'])) {
                 $res['result'] = 'success';
             } else {
                 $res['result'] = 'failure';
             }
             break;
         default:
             ApiBase::dieDebug(__METHOD__, "Unhandled concurrency action: {$params['ccaction']}");
     }
     $this->getResult()->addValue(null, $this->getModuleName(), $res);
 }
Пример #20
0
 public function execute()
 {
     $name = $password = $domain = null;
     extract($this->extractRequestParams());
     $params = new FauxRequest(array('wpName' => $name, 'wpPassword' => $password, 'wpDomain' => $domain, 'wpRemember' => ''));
     $result = array();
     $loginForm = new LoginForm($params);
     switch ($loginForm->authenticateUserData()) {
         case LoginForm::SUCCESS:
             global $wgUser;
             $wgUser->setOption('rememberpassword', 1);
             $wgUser->setCookies();
             $result['result'] = 'Success';
             $result['lguserid'] = $_SESSION['wsUserID'];
             $result['lgusername'] = $_SESSION['wsUserName'];
             $result['lgtoken'] = $_SESSION['wsToken'];
             break;
         case LoginForm::NO_NAME:
             $result['result'] = 'NoName';
             break;
         case LoginForm::ILLEGAL:
             $result['result'] = 'Illegal';
             break;
         case LoginForm::WRONG_PLUGIN_PASS:
             $result['result'] = 'WrongPluginPass';
             break;
         case LoginForm::NOT_EXISTS:
             $result['result'] = 'NotExists';
             break;
         case LoginForm::WRONG_PASS:
             $result['result'] = 'WrongPass';
             break;
         case LoginForm::EMPTY_PASS:
             $result['result'] = 'EmptyPass';
             break;
         default:
             ApiBase::dieDebug(__METHOD__, 'Unhandled case value');
     }
     $this->getResult()->addValue(null, 'login', $result);
 }
 public function __construct(ApiQuery $query, $moduleName)
 {
     switch ($moduleName) {
         case 'alllinks':
             $prefix = 'al';
             $this->table = 'pagelinks';
             $this->tablePrefix = 'pl_';
             $this->useIndex = 'pl_namespace';
             $this->indexTag = 'l';
             break;
         case 'alltransclusions':
             $prefix = 'at';
             $this->table = 'templatelinks';
             $this->tablePrefix = 'tl_';
             $this->dfltNamespace = NS_TEMPLATE;
             $this->useIndex = 'tl_namespace';
             $this->indexTag = 't';
             break;
         case 'allfileusages':
             $prefix = 'af';
             $this->table = 'imagelinks';
             $this->tablePrefix = 'il_';
             $this->fieldTitle = 'to';
             $this->dfltNamespace = NS_FILE;
             $this->hasNamespace = false;
             $this->indexTag = 'f';
             break;
         case 'allredirects':
             $prefix = 'ar';
             $this->table = 'redirect';
             $this->tablePrefix = 'rd_';
             $this->indexTag = 'r';
             $this->props = array('fragment' => 'rd_fragment', 'interwiki' => 'rd_interwiki');
             break;
         default:
             ApiBase::dieDebug(__METHOD__, 'Unknown module name');
     }
     parent::__construct($query, $moduleName, $prefix);
 }
Пример #22
0
 /**
  * Recursivelly go through the object and output its data in WDDX format.
  */
 function slowWddxPrinter($elemValue)
 {
     switch (gettype($elemValue)) {
         case 'array':
             $this->printText('<struct>');
             foreach ($elemValue as $subElemName => $subElemValue) {
                 $this->printText(wfElement('var', array('name' => $subElemName), null));
                 $this->slowWddxPrinter($subElemValue);
                 $this->printText('</var>');
             }
             $this->printText('</struct>');
             break;
         case 'integer':
         case 'double':
             $this->printText(wfElement('number', null, $elemValue));
             break;
         case 'string':
             $this->printText(wfElement('string', null, $elemValue));
             break;
         default:
             ApiBase::dieDebug(__METHOD__, 'Unknown type ' . gettype($elemValue));
     }
 }
 /**
  * APIAfterExecute hook handler
  * @see: https://www.mediawiki.org/wiki/Manual:Hooks/
  * @param ApiBase $module
  * @return bool
  */
 public static function onAPIAfterExecute(ApiBase &$module)
 {
     global $wgMFSpecialCaseMainPage;
     if ($module->getModuleName() == 'parse') {
         if (defined('ApiResult::META_CONTENT')) {
             $data = $module->getResult()->getResultData();
         } else {
             $data = $module->getResultData();
         }
         $params = $module->extractRequestParams();
         if (isset($data['parse']['text']) && $params['mobileformat']) {
             $result = $module->getResult();
             $result->reset();
             $title = Title::newFromText($data['parse']['title']);
             $text = $data['parse']['text'];
             if (is_array($text)) {
                 if (defined('ApiResult::META_CONTENT') && isset($text[ApiResult::META_CONTENT])) {
                     $contentKey = $text[ApiResult::META_CONTENT];
                 } else {
                     $contentKey = '*';
                 }
                 $html = MobileFormatter::wrapHTML($text[$contentKey]);
             } else {
                 $html = MobileFormatter::wrapHTML($text);
             }
             $mf = new MobileFormatter($html, $title);
             $mf->setRemoveMedia($params['noimages']);
             $mf->setIsMainPage($params['mainpage'] && $wgMFSpecialCaseMainPage);
             $mf->enableExpandableSections(!$params['mainpage']);
             // HACK: need a nice way to request a TOC- and edit link-free HTML in the first place
             // FIXME: Should this be .mw-editsection?
             $mf->remove(array('.toc', 'mw-editsection', '.mw-headline-anchor'));
             $mf->filterContent();
             if (is_array($text)) {
                 $text[$contentKey] = $mf->getText();
             } else {
                 $text = $mf->getText();
             }
             $data['parse']['text'] = $text;
             $result->addValue(null, $module->getModuleName(), $data['parse']);
         }
     }
     return true;
 }
Пример #24
0
 public function __construct(ApiQuery $query, $moduleName)
 {
     switch ($moduleName) {
         case self::LINKS:
             $this->table = 'pagelinks';
             $this->prefix = 'pl';
             $this->description = 'link';
             $this->titlesParam = 'titles';
             $this->titlesParamDescription = 'Only list links to these titles. Useful ' . 'for checking whether a certain page links to a certain title.';
             $this->helpUrl = 'https://www.mediawiki.org/wiki/API:Properties#links_.2F_pl';
             break;
         case self::TEMPLATES:
             $this->table = 'templatelinks';
             $this->prefix = 'tl';
             $this->description = 'template';
             $this->titlesParam = 'templates';
             $this->titlesParamDescription = 'Only list these templates. Useful ' . 'for checking whether a certain page uses a certain template.';
             $this->helpUrl = 'https://www.mediawiki.org/wiki/API:Properties#templates_.2F_tl';
             break;
         default:
             ApiBase::dieDebug(__METHOD__, 'Unknown module name');
     }
     parent::__construct($query, $moduleName, $this->prefix);
 }
 /**
  * Generates and outputs the result of this query based upon the provided parameters.
  *
  * @param ApiPageSet $resultPageSet
  */
 public function run($resultPageSet = null)
 {
     $user = $this->getUser();
     /* Get the parameters of the request. */
     $params = $this->extractRequestParams();
     /* Build our basic query. Namely, something along the lines of:
      * SELECT * FROM recentchanges WHERE rc_timestamp > $start
      * 		AND rc_timestamp < $end AND rc_namespace = $namespace
      */
     $this->addTables('recentchanges');
     $index = array('recentchanges' => 'rc_timestamp');
     // May change
     $this->addTimestampWhereRange('rc_timestamp', $params['dir'], $params['start'], $params['end']);
     if (!is_null($params['continue'])) {
         $cont = explode('|', $params['continue']);
         $this->dieContinueUsageIf(count($cont) != 2);
         $db = $this->getDB();
         $timestamp = $db->addQuotes($db->timestamp($cont[0]));
         $id = intval($cont[1]);
         $this->dieContinueUsageIf($id != $cont[1]);
         $op = $params['dir'] === 'older' ? '<' : '>';
         $this->addWhere("rc_timestamp {$op} {$timestamp} OR " . "(rc_timestamp = {$timestamp} AND " . "rc_id {$op}= {$id})");
     }
     $order = $params['dir'] === 'older' ? 'DESC' : 'ASC';
     $this->addOption('ORDER BY', array("rc_timestamp {$order}", "rc_id {$order}"));
     $this->addWhereFld('rc_namespace', $params['namespace']);
     if (!is_null($params['type'])) {
         try {
             $this->addWhereFld('rc_type', RecentChange::parseToRCType($params['type']));
         } catch (Exception $e) {
             ApiBase::dieDebug(__METHOD__, $e->getMessage());
         }
     }
     if (!is_null($params['show'])) {
         $show = array_flip($params['show']);
         /* Check for conflicting parameters. */
         if (isset($show['minor']) && isset($show['!minor']) || isset($show['bot']) && isset($show['!bot']) || isset($show['anon']) && isset($show['!anon']) || isset($show['redirect']) && isset($show['!redirect']) || isset($show['patrolled']) && isset($show['!patrolled']) || isset($show['patrolled']) && isset($show['unpatrolled']) || isset($show['!patrolled']) && isset($show['unpatrolled'])) {
             $this->dieUsageMsg('show');
         }
         // Check permissions
         if (isset($show['patrolled']) || isset($show['!patrolled']) || isset($show['unpatrolled'])) {
             if (!$user->useRCPatrol() && !$user->useNPPatrol()) {
                 $this->dieUsage('You need the patrol right to request the patrolled flag', 'permissiondenied');
             }
         }
         /* Add additional conditions to query depending upon parameters. */
         $this->addWhereIf('rc_minor = 0', isset($show['!minor']));
         $this->addWhereIf('rc_minor != 0', isset($show['minor']));
         $this->addWhereIf('rc_bot = 0', isset($show['!bot']));
         $this->addWhereIf('rc_bot != 0', isset($show['bot']));
         $this->addWhereIf('rc_user = 0', isset($show['anon']));
         $this->addWhereIf('rc_user != 0', isset($show['!anon']));
         $this->addWhereIf('rc_patrolled = 0', isset($show['!patrolled']));
         $this->addWhereIf('rc_patrolled != 0', isset($show['patrolled']));
         $this->addWhereIf('page_is_redirect = 1', isset($show['redirect']));
         if (isset($show['unpatrolled'])) {
             // See ChangesList:isUnpatrolled
             if ($user->useRCPatrol()) {
                 $this->addWhere('rc_patrolled = 0');
             } elseif ($user->useNPPatrol()) {
                 $this->addWhere('rc_patrolled = 0');
                 $this->addWhereFld('rc_type', RC_NEW);
             }
         }
         // Don't throw log entries out the window here
         $this->addWhereIf('page_is_redirect = 0 OR page_is_redirect IS NULL', isset($show['!redirect']));
     }
     if (!is_null($params['user']) && !is_null($params['excludeuser'])) {
         $this->dieUsage('user and excludeuser cannot be used together', 'user-excludeuser');
     }
     if (!is_null($params['user'])) {
         $this->addWhereFld('rc_user_text', $params['user']);
         $index['recentchanges'] = 'rc_user_text';
     }
     if (!is_null($params['excludeuser'])) {
         // We don't use the rc_user_text index here because
         // * it would require us to sort by rc_user_text before rc_timestamp
         // * the != condition doesn't throw out too many rows anyway
         $this->addWhere('rc_user_text != ' . $this->getDB()->addQuotes($params['excludeuser']));
     }
     /* Add the fields we're concerned with to our query. */
     $this->addFields(array('rc_id', 'rc_timestamp', 'rc_namespace', 'rc_title', 'rc_cur_id', 'rc_type', 'rc_deleted'));
     $showRedirects = false;
     /* Determine what properties we need to display. */
     if (!is_null($params['prop'])) {
         $prop = array_flip($params['prop']);
         /* Set up internal members based upon params. */
         $this->initProperties($prop);
         if ($this->fld_patrolled && !$user->useRCPatrol() && !$user->useNPPatrol()) {
             $this->dieUsage('You need the patrol right to request the patrolled flag', 'permissiondenied');
         }
         /* Add fields to our query if they are specified as a needed parameter. */
         $this->addFieldsIf(array('rc_this_oldid', 'rc_last_oldid'), $this->fld_ids);
         $this->addFieldsIf('rc_comment', $this->fld_comment || $this->fld_parsedcomment);
         $this->addFieldsIf('rc_user', $this->fld_user || $this->fld_userid);
         $this->addFieldsIf('rc_user_text', $this->fld_user);
         $this->addFieldsIf(array('rc_minor', 'rc_type', 'rc_bot'), $this->fld_flags);
         $this->addFieldsIf(array('rc_old_len', 'rc_new_len'), $this->fld_sizes);
         $this->addFieldsIf('rc_patrolled', $this->fld_patrolled);
         $this->addFieldsIf(array('rc_logid', 'rc_log_type', 'rc_log_action', 'rc_params'), $this->fld_loginfo);
         $showRedirects = $this->fld_redirect || isset($show['redirect']) || isset($show['!redirect']);
     }
     if ($this->fld_tags) {
         $this->addTables('tag_summary');
         $this->addJoinConds(array('tag_summary' => array('LEFT JOIN', array('rc_id=ts_rc_id'))));
         $this->addFields('ts_tags');
     }
     if ($this->fld_sha1) {
         $this->addTables('revision');
         $this->addJoinConds(array('revision' => array('LEFT JOIN', array('rc_this_oldid=rev_id'))));
         $this->addFields(array('rev_sha1', 'rev_deleted'));
     }
     if ($params['toponly'] || $showRedirects) {
         $this->addTables('page');
         $this->addJoinConds(array('page' => array('LEFT JOIN', array('rc_namespace=page_namespace', 'rc_title=page_title'))));
         $this->addFields('page_is_redirect');
         if ($params['toponly']) {
             $this->addWhere('rc_this_oldid = page_latest');
         }
     }
     if (!is_null($params['tag'])) {
         $this->addTables('change_tag');
         $this->addJoinConds(array('change_tag' => array('INNER JOIN', array('rc_id=ct_rc_id'))));
         $this->addWhereFld('ct_tag', $params['tag']);
     }
     // Paranoia: avoid brute force searches (bug 17342)
     if (!is_null($params['user']) || !is_null($params['excludeuser'])) {
         if (!$user->isAllowed('deletedhistory')) {
             $bitmask = Revision::DELETED_USER;
         } elseif (!$user->isAllowedAny('suppressrevision', 'viewsuppressed')) {
             $bitmask = Revision::DELETED_USER | Revision::DELETED_RESTRICTED;
         } else {
             $bitmask = 0;
         }
         if ($bitmask) {
             $this->addWhere($this->getDB()->bitAnd('rc_deleted', $bitmask) . " != {$bitmask}");
         }
     }
     if ($this->getRequest()->getCheck('namespace')) {
         // LogPage::DELETED_ACTION hides the affected page, too.
         if (!$user->isAllowed('deletedhistory')) {
             $bitmask = LogPage::DELETED_ACTION;
         } elseif (!$user->isAllowedAny('suppressrevision', 'viewsuppressed')) {
             $bitmask = LogPage::DELETED_ACTION | LogPage::DELETED_RESTRICTED;
         } else {
             $bitmask = 0;
         }
         if ($bitmask) {
             $this->addWhere($this->getDB()->makeList(array('rc_type != ' . RC_LOG, $this->getDB()->bitAnd('rc_deleted', $bitmask) . " != {$bitmask}"), LIST_OR));
         }
     }
     $this->token = $params['token'];
     $this->addOption('LIMIT', $params['limit'] + 1);
     $this->addOption('USE INDEX', $index);
     $count = 0;
     /* Perform the actual query. */
     $res = $this->select(__METHOD__);
     $titles = array();
     $result = $this->getResult();
     /* Iterate through the rows, adding data extracted from them to our query result. */
     foreach ($res as $row) {
         if (++$count > $params['limit']) {
             // We've reached the one extra which shows that there are
             // additional pages to be had. Stop here...
             $this->setContinueEnumParameter('continue', "{$row->rc_timestamp}|{$row->rc_id}");
             break;
         }
         if (is_null($resultPageSet)) {
             /* Extract the data from a single row. */
             $vals = $this->extractRowInfo($row);
             /* Add that row's data to our final output. */
             $fit = $result->addValue(array('query', $this->getModuleName()), null, $vals);
             if (!$fit) {
                 $this->setContinueEnumParameter('continue', "{$row->rc_timestamp}|{$row->rc_id}");
                 break;
             }
         } else {
             $titles[] = Title::makeTitle($row->rc_namespace, $row->rc_title);
         }
     }
     if (is_null($resultPageSet)) {
         /* Format the result */
         $result->addIndexedTagName(array('query', $this->getModuleName()), 'rc');
     } else {
         $resultPageSet->populateFromTitles($titles);
     }
 }
Пример #26
0
 public function getPossibleErrors()
 {
     return array_merge(parent::getPossibleErrors(), array(array('code' => 'params', 'info' => 'The page parameter cannot be used together with the text and title parameters'), array('code' => 'params', 'info' => 'The text parameter should be passed with the title parameter. Should you be using the "page" parameter instead?'), array('code' => 'missingrev', 'info' => 'There is no revision ID oldid'), array('code' => 'permissiondenied', 'info' => 'You don\'t have permission to view deleted revisions'), array('code' => 'missingtitle', 'info' => 'The page you specified doesn\'t exist'), array('code' => 'nosuchsection', 'info' => 'There is no section sectionnumber in page'), array('nosuchpageid'), array('invalidtitle', 'title'), array('code' => 'parseerror', 'info' => 'Failed to parse the given text.'), array('code' => 'notwikitext', 'info' => 'The requested operation is only supported on wikitext content.'), array('code' => 'pagecannotexist', 'info' => "Namespace doesn't allow actual pages")));
 }
Пример #27
0
 public function getPossibleErrors()
 {
     return array_merge(parent::getPossibleErrors(), array(array('missingparam', 'locations')));
 }
Пример #28
0
 /**
  * @return array
  */
 public function getPossibleErrors()
 {
     return array_merge(parent::getPossibleErrors(), array(array('invalidtitle', 'title'), array('invalidtitle', 'key')));
 }
Пример #29
0
 public function getPossibleErrors()
 {
     return array_merge(parent::getPossibleErrors(), array(array('invalidtitle', 'title'), array('notanarticle'), array('invaliduser', 'user')));
 }
Пример #30
0
 public function getPossibleErrors()
 {
     return array_merge(parent::getPossibleErrors(), array(array('code' => 'NeedToken', 'info' => 'You need to resubmit your login with the specified token. See https://bugzilla.wikimedia.org/show_bug.cgi?id=23076'), array('code' => 'WrongToken', 'info' => 'You specified an invalid token'), array('code' => 'NoName', 'info' => 'You didn\'t set the lgname parameter'), array('code' => 'Illegal', 'info' => ' You provided an illegal username'), array('code' => 'NotExists', 'info' => ' The username you provided doesn\'t exist'), array('code' => 'EmptyPass', 'info' => ' You didn\'t set the lgpassword parameter or you left it empty'), array('code' => 'WrongPass', 'info' => ' The password you provided is incorrect'), array('code' => 'WrongPluginPass', 'info' => 'Same as "WrongPass", returned when an authentication plugin rather than MediaWiki itself rejected the password'), array('code' => 'CreateBlocked', 'info' => 'The wiki tried to automatically create a new account for you, but your IP address has been blocked from account creation'), array('code' => 'Throttled', 'info' => 'You\'ve logged in too many times in a short time'), array('code' => 'Blocked', 'info' => 'User is blocked')));
 }