Index: trunk/phase3/RELEASE-NOTES-1.19 |
— | — | @@ -205,6 +205,7 @@ |
206 | 206 | many types. |
207 | 207 | * (bug 32415) Empty page get no size attribute in API output. |
208 | 208 | * (bug 31759) Undefined property notice in querypages API. |
| 209 | +* (bug 32495) API should allow purge by pageids. |
209 | 210 | |
210 | 211 | === Languages updated in 1.19 === |
211 | 212 | |
Index: trunk/phase3/includes/api/ApiPurge.php |
— | — | @@ -47,17 +47,32 @@ |
48 | 48 | } |
49 | 49 | |
50 | 50 | $forceLinkUpdate = $params['forcelinkupdate']; |
| 51 | + $pageSet = new ApiPageSet( $this ); |
| 52 | + $pageSet->execute(); |
51 | 53 | |
52 | 54 | $result = array(); |
53 | | - foreach ( $params['titles'] as $t ) { |
| 55 | + foreach( $pageSet->getInvalidTitles() as $title ) { |
54 | 56 | $r = array(); |
55 | | - $title = Title::newFromText( $t ); |
56 | | - if ( !$title instanceof Title ) { |
57 | | - $r['title'] = $t; |
58 | | - $r['invalid'] = ''; |
59 | | - $result[] = $r; |
60 | | - continue; |
61 | | - } |
| 57 | + $r['title'] = $title; |
| 58 | + $r['invalid'] = ''; |
| 59 | + $result[] = $r; |
| 60 | + } |
| 61 | + foreach( $pageSet->getMissingPageIDs() as $p ) { |
| 62 | + $page = array(); |
| 63 | + $page['pageid'] = $p; |
| 64 | + $page['missing'] = ''; |
| 65 | + $result[] = $page; |
| 66 | + } |
| 67 | + foreach( $pageSet->getMissingPageIDs() as $r ) { |
| 68 | + $rev = array(); |
| 69 | + $rev['revid'] = $r; |
| 70 | + $rev['missing'] = ''; |
| 71 | + $result[] = $rev; |
| 72 | + } |
| 73 | + |
| 74 | + foreach ( $pageSet->getTitles() as $title ) { |
| 75 | + $r = array(); |
| 76 | + |
62 | 77 | ApiQueryBase::addTitleInfo( $r, $title ); |
63 | 78 | if ( !$title->exists() ) { |
64 | 79 | $r['missing'] = ''; |
— | — | @@ -104,18 +119,15 @@ |
105 | 120 | } |
106 | 121 | |
107 | 122 | public function getAllowedParams() { |
108 | | - return array( |
109 | | - 'titles' => array( |
110 | | - ApiBase::PARAM_ISMULTI => true, |
111 | | - ApiBase::PARAM_REQUIRED => true |
112 | | - ), |
| 123 | + $psModule = new ApiPageSet( $this ); |
| 124 | + return $psModule->getAllowedParams() + array( |
113 | 125 | 'forcelinkupdate' => false, |
114 | 126 | ); |
115 | 127 | } |
116 | 128 | |
117 | 129 | public function getParamDescription() { |
118 | | - return array( |
119 | | - 'titles' => 'A list of titles', |
| 130 | + $psModule = new ApiPageSet( $this ); |
| 131 | + return $psModule->getParamDescription() + array( |
120 | 132 | 'forcelinkupdate' => 'Update the links tables', |
121 | 133 | ); |
122 | 134 | } |
— | — | @@ -127,9 +139,12 @@ |
128 | 140 | } |
129 | 141 | |
130 | 142 | public function getPossibleErrors() { |
131 | | - return array_merge( parent::getPossibleErrors(), array( |
132 | | - array( 'cantpurge' ), |
133 | | - ) ); |
| 143 | + $psModule = new ApiPageSet( $this ); |
| 144 | + return array_merge( |
| 145 | + parent::getPossibleErrors(), |
| 146 | + array( array( 'cantpurge' ), ), |
| 147 | + $psModule->getPossibleErrors() |
| 148 | + ); |
134 | 149 | } |
135 | 150 | |
136 | 151 | public function getExamples() { |
Index: trunk/phase3/includes/api/ApiQueryBase.php |
— | — | @@ -35,6 +35,11 @@ |
36 | 36 | |
37 | 37 | private $mQueryModule, $mDb, $tables, $where, $fields, $options, $join_conds; |
38 | 38 | |
| 39 | + /** |
| 40 | + * @param $query ApiBase |
| 41 | + * @param $moduleName string |
| 42 | + * @param $paramPrefix string |
| 43 | + */ |
39 | 44 | public function __construct( ApiBase $query, $moduleName, $paramPrefix = '' ) { |
40 | 45 | parent::__construct( $query->getMain(), $moduleName, $paramPrefix ); |
41 | 46 | $this->mQueryModule = $query; |