X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiFeedWatchlist.php;h=bfa750bfa415519c4a299fc055ec014368e500bf;hb=ff12720cda81ab0b3eabe6fb7b3f529d6ec7243b;hp=983b6a81f2220c0692cbf8fcc7a6ae6a1cefae30;hpb=d65e736864d17ecc84385a26295e5859de2f9fee;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiFeedWatchlist.php b/includes/api/ApiFeedWatchlist.php index 983b6a81f2..bfa750bfa4 100644 --- a/includes/api/ApiFeedWatchlist.php +++ b/includes/api/ApiFeedWatchlist.php @@ -117,7 +117,10 @@ class ApiFeedWatchlist extends ApiBase { $feedItems = array(); foreach ( (array)$data['query']['watchlist'] as $info ) { - $feedItems[] = $this->createFeedItem( $info ); + $feedItem = $this->createFeedItem( $info ); + if ( $feedItem ) { + $feedItems[] = $feedItem; + } } $msg = wfMessage( 'watchlist' )->inContentLanguage()->text(); @@ -166,10 +169,22 @@ class ApiFeedWatchlist extends ApiBase { private function createFeedItem( $info ) { $titleStr = $info['title']; $title = Title::newFromText( $titleStr ); + $curidParam = array(); + if ( !$title || $title->isExternal() ) { + // Probably a formerly-valid title that's now conflicting with an + // interwiki prefix or the like. + if ( isset( $info['pageid'] ) ) { + $title = Title::newFromId( $info['pageid'] ); + $curidParam = array( 'curid' => $info['pageid'] ); + } + if ( !$title || $title->isExternal() ) { + return null; + } + } if ( isset( $info['revid'] ) ) { $titleUrl = $title->getFullURL( array( 'diff' => $info['revid'] ) ); } else { - $titleUrl = $title->getFullURL(); + $titleUrl = $title->getFullURL( $curidParam ); } $comment = isset( $info['comment'] ) ? $info['comment'] : null; @@ -219,57 +234,42 @@ class ApiFeedWatchlist extends ApiBase { ), 'linktosections' => false, ); + + $copyParams = array( + 'allrev' => 'allrev', + 'owner' => 'wlowner', + 'token' => 'wltoken', + 'show' => 'wlshow', + 'type' => 'wltype', + 'excludeuser' => 'wlexcludeuser', + ); if ( $flags ) { $wlparams = $this->getWatchlistModule()->getAllowedParams( $flags ); - $ret['allrev'] = $wlparams['allrev']; - $ret['wlowner'] = $wlparams['owner']; - $ret['wltoken'] = $wlparams['token']; - $ret['wlshow'] = $wlparams['show']; - $ret['wltype'] = $wlparams['type']; - $ret['wlexcludeuser'] = $wlparams['excludeuser']; + foreach ( $copyParams as $from => $to ) { + $p = $wlparams[$from]; + if ( !is_array( $p ) ) { + $p = array( ApiBase::PARAM_DFLT => $p ); + } + if ( !isset( $p[ApiBase::PARAM_HELP_MSG] ) ) { + $p[ApiBase::PARAM_HELP_MSG] = "apihelp-query+watchlist-param-$from"; + } + $ret[$to] = $p; + } } else { - $ret['allrev'] = null; - $ret['wlowner'] = null; - $ret['wltoken'] = null; - $ret['wlshow'] = null; - $ret['wltype'] = null; - $ret['wlexcludeuser'] = null; + foreach ( $copyParams as $from => $to ) { + $ret[$to] = null; + } } return $ret; } - public function getParamDescription() { - $wldescr = $this->getWatchlistModule()->getParamDescription(); - - return array( - 'feedformat' => 'The format of the feed', - 'hours' => 'List pages modified within this many hours from now', - 'linktosections' => 'Link directly to changed sections if possible', - 'allrev' => $wldescr['allrev'], - 'wlowner' => $wldescr['owner'], - 'wltoken' => $wldescr['token'], - 'wlshow' => $wldescr['show'], - 'wltype' => $wldescr['type'], - 'wlexcludeuser' => $wldescr['excludeuser'], - ); - } - - public function getDescription() { - return 'Returns a watchlist feed.'; - } - - public function getPossibleErrors() { - return array_merge( parent::getPossibleErrors(), array( - array( 'code' => 'feed-unavailable', 'info' => 'Syndication feeds are not available' ), - array( 'code' => 'feed-invalid', 'info' => 'Invalid subscription feed type' ), - ) ); - } - - public function getExamples() { + protected function getExamplesMessages() { return array( - 'api.php?action=feedwatchlist', - 'api.php?action=feedwatchlist&allrev=&hours=6' + 'action=feedwatchlist' + => 'apihelp-feedwatchlist-example-default', + 'action=feedwatchlist&allrev=&hours=6' + => 'apihelp-feedwatchlist-example-all6hrs', ); }