Index: trunk/phase3/includes/api/ApiQueryBase.php |
— | — | @@ -36,7 +36,10 @@ |
37 | 37 | public function __construct($query, $moduleName, $paramPrefix = '') { |
38 | 38 | parent :: __construct($query->getMain(), $moduleName, $paramPrefix); |
39 | 39 | $this->mQueryModule = $query; |
40 | | - |
| 40 | + $this->resetQueryParams(); |
| 41 | + } |
| 42 | + |
| 43 | + protected function resetQueryParams() { |
41 | 44 | $this->tables = array (); |
42 | 45 | $this->where = array (); |
43 | 46 | $this->fields = array(); |
Index: trunk/phase3/includes/api/ApiQuery.php |
— | — | @@ -50,7 +50,9 @@ |
51 | 51 | 'logevents' => 'ApiQueryLogEvents', |
52 | 52 | 'watchlist' => 'ApiQueryWatchlist', |
53 | 53 | 'recentchanges' => 'ApiQueryRecentChanges', |
54 | | - 'backlinks' => 'ApiQueryBacklinks' |
| 54 | + 'backlinks' => 'ApiQueryBacklinks', |
| 55 | + 'embeddedin' => 'ApiQueryBacklinks', |
| 56 | + 'imagelinks' => 'ApiQueryBacklinks' |
55 | 57 | ); |
56 | 58 | // 'categorymembers' => 'ApiQueryCategorymembers', |
57 | 59 | // 'embeddedin' => 'ApiQueryEmbeddedin', |
Index: trunk/phase3/includes/api/ApiQueryRevisions.php |
— | — | @@ -118,7 +118,7 @@ |
119 | 119 | $this->validateLimit($this->encodeParamName('limit'), $limit, 1, $userMax, $botMax); |
120 | 120 | |
121 | 121 | // There is only one ID, use it |
122 | | - $this->addWhereFld('rev_page', array_pop(array_keys($pageSet->getGoodTitles()))); |
| 122 | + $this->addWhereFld('rev_page', current(array_keys($pageSet->getGoodTitles()))); |
123 | 123 | } |
124 | 124 | elseif ($pageCount > 0) { |
125 | 125 | // When working in multi-page non-enumeration mode, |
Index: trunk/phase3/includes/api/ApiBase.php |
— | — | @@ -170,14 +170,17 @@ |
171 | 171 | $desc = isset ($paramsDescription[$paramName]) ? $paramsDescription[$paramName] : ''; |
172 | 172 | if (is_array($desc)) |
173 | 173 | $desc = implode($paramPrefix, $desc); |
| 174 | + |
174 | 175 | if (isset ($paramSettings[self :: PARAM_TYPE])) { |
| 176 | + if (isset ($paramSettings[self :: PARAM_ISMULTI])) |
| 177 | + $prompt = 'Multiple "|"-separated values: '; |
| 178 | + else |
| 179 | + $prompt = 'Any one of these values: '; |
175 | 180 | $type = $paramSettings[self :: PARAM_TYPE]; |
176 | 181 | if (is_array($type)) |
177 | | - $desc .= $paramPrefix . 'Allowed values: ' . implode(', ', $type); |
| 182 | + $desc .= $paramPrefix . $prompt . implode(', ', $type); |
178 | 183 | } |
179 | | - if (isset ($paramSettings[self :: PARAM_ISMULTI])) |
180 | | - $desc .= $paramPrefix . 'Allows multiple values separated with "|"'; |
181 | | - |
| 184 | + |
182 | 185 | $default = is_array($paramSettings) ? (isset ($paramSettings[self :: PARAM_DFLT]) ? $paramSettings[self :: PARAM_DFLT] : null) : $paramSettings; |
183 | 186 | if (!is_null($default) && $default !== false) |
184 | 187 | $desc .= $paramPrefix . "Default: $default"; |
— | — | @@ -327,7 +330,6 @@ |
328 | 331 | break; |
329 | 332 | default : |
330 | 333 | ApiBase :: dieDebug(__METHOD__, "Param $paramName's type is unknown - $type"); |
331 | | - |
332 | 334 | } |
333 | 335 | } |
334 | 336 | |
— | — | @@ -437,7 +439,7 @@ |
438 | 440 | $this->profileOut(); |
439 | 441 | } |
440 | 442 | } |
441 | | - |
| 443 | + |
442 | 444 | /** |
443 | 445 | * Total time the module was executed |
444 | 446 | */ |
Index: trunk/phase3/includes/api/ApiMain.php |
— | — | @@ -271,9 +271,21 @@ |
272 | 272 | '', |
273 | 273 | 'This API allows programs to access various functions of MediaWiki software.', |
274 | 274 | 'For more details see API Home Page @ http://meta.wikimedia.org/wiki/API', |
| 275 | + '', |
| 276 | + 'Status: ALPHA -- all features shown on this page should be working,', |
| 277 | + ' but the API is still in active development, and may change at any time.', |
| 278 | + ' Make sure you monitor changes to this page, wikitech-l mailing list,', |
| 279 | + ' or the source code in the includes/api directory for any changes.', |
275 | 280 | '' |
276 | 281 | ); |
277 | 282 | } |
| 283 | + |
| 284 | + protected function getCredits() { |
| 285 | + return array( |
| 286 | + 'This API is being implemented by Yuri Astrakhan [[User:Yurik]] / FirstnameLastname@gmail.com', |
| 287 | + 'Please leave your comments and suggestions at http://meta.wikimedia.org/wiki/API' |
| 288 | + ); |
| 289 | + } |
278 | 290 | |
279 | 291 | /** |
280 | 292 | * Override the parent to generate help messages for all available modules. |
— | — | @@ -303,6 +315,9 @@ |
304 | 316 | $msg .= $msg2; |
305 | 317 | $msg .= "\n"; |
306 | 318 | } |
| 319 | + |
| 320 | + $msg .= "\n*** Credits: ***\n " . implode("\n ", $this->getCredits()) . "\n"; |
| 321 | + |
307 | 322 | |
308 | 323 | return $msg; |
309 | 324 | } |
Index: trunk/phase3/includes/api/ApiQueryBacklinks.php |
— | — | @@ -33,8 +33,53 @@ |
34 | 34 | |
35 | 35 | private $rootTitle, $contRedirs, $contLevel, $contTitle, $contID; |
36 | 36 | |
| 37 | + // output element name, database column field prefix, database table |
| 38 | + private $backlinksSettings = array ( |
| 39 | + 'backlinks' => array ( |
| 40 | + 'code' => 'bl', |
| 41 | + 'prefix' => 'pl', |
| 42 | + 'linktbl' => 'pagelinks' |
| 43 | + ), |
| 44 | + 'embeddedin' => array ( |
| 45 | + 'code' => 'ei', |
| 46 | + 'prefix' => 'tl', |
| 47 | + 'linktbl' => 'templatelinks' |
| 48 | + ), |
| 49 | + 'imagelinks' => array ( |
| 50 | + 'code' => 'il', |
| 51 | + 'prefix' => 'il', |
| 52 | + 'linktbl' => 'imagelinks' |
| 53 | + ) |
| 54 | + ); |
| 55 | + |
37 | 56 | public function __construct($query, $moduleName) { |
38 | | - parent :: __construct($query, $moduleName, 'bl'); |
| 57 | + $code = $prefix = $linktbl = null; |
| 58 | + extract($this->backlinksSettings[$moduleName]); |
| 59 | + |
| 60 | + parent :: __construct($query, $moduleName, $code); |
| 61 | + $this->bl_ns = $prefix . '_namespace'; |
| 62 | + $this->bl_from = $prefix . '_from'; |
| 63 | + $this->bl_tables = array ( |
| 64 | + $linktbl, |
| 65 | + 'page' |
| 66 | + ); |
| 67 | + $this->bl_code = $code; |
| 68 | + |
| 69 | + $this->hasNS = $moduleName !== 'imagelinks'; |
| 70 | + if ($this->hasNS) { |
| 71 | + $this->bl_title = $prefix . '_title'; |
| 72 | + $this->bl_sort = "{$this->bl_ns}, {$this->bl_title}, {$this->bl_from}"; |
| 73 | + $this->bl_fields = array ( |
| 74 | + $this->bl_ns, |
| 75 | + $this->bl_title |
| 76 | + ); |
| 77 | + } else { |
| 78 | + $this->bl_title = $prefix . '_to'; |
| 79 | + $this->bl_sort = "{$this->bl_title}, {$this->bl_from}"; |
| 80 | + $this->bl_fields = array ( |
| 81 | + $this->bl_title |
| 82 | + ); |
| 83 | + } |
39 | 84 | } |
40 | 85 | |
41 | 86 | public function execute() { |
— | — | @@ -54,34 +99,25 @@ |
55 | 100 | |
56 | 101 | $this->processContinue($continue, $redirect); |
57 | 102 | |
58 | | - if (is_null($resultPageSet)) { |
| 103 | + $this->addFields($this->bl_fields); |
| 104 | + if (is_null($resultPageSet)) |
59 | 105 | $this->addFields(array ( |
60 | | - 'pl_from as page_id', // is this more efficient than getting page_id? |
61 | | - 'pl_namespace', |
62 | | - 'pl_title', |
| 106 | + 'page_id', |
63 | 107 | 'page_namespace', |
64 | 108 | 'page_title' |
65 | 109 | )); |
66 | | - } else { |
67 | | - $this->addFields($resultPageSet->getPageTableFields()); |
68 | | - $this->addFields(array ( |
69 | | - 'pl_namespace', |
70 | | - 'pl_title', |
71 | | - |
72 | | - )); |
73 | | - } |
| 110 | + else |
| 111 | + $this->addFields($resultPageSet->getPageTableFields()); // will include page_id |
74 | 112 | |
75 | | - $this->addTables(array ( |
76 | | - 'pagelinks', |
77 | | - 'page' |
78 | | - )); |
79 | | - $this->addWhere('pl_from=page_id'); |
| 113 | + $this->addTables($this->bl_tables); |
| 114 | + $this->addWhere($this->bl_from . '=page_id'); |
80 | 115 | |
81 | | - $this->addWhereFld('pl_namespace', $this->rootTitle->getNamespace()); |
82 | | - $this->addWhereFld('pl_title', $this->rootTitle->getDBkey()); |
| 116 | + if ($this->hasNS) |
| 117 | + $this->addWhereFld($this->bl_ns, $this->rootTitle->getNamespace()); |
| 118 | + $this->addWhereFld($this->bl_title, $this->rootTitle->getDBkey()); |
83 | 119 | $this->addWhereFld('page_namespace', $namespace); |
84 | 120 | $this->addOption('LIMIT', $limit +1); |
85 | | - $this->addOption('ORDER BY', 'pl_namespace, pl_title, pl_from'); |
| 121 | + $this->addOption('ORDER BY', $this->bl_sort); |
86 | 122 | |
87 | 123 | if ($redirect) |
88 | 124 | $this->addWhereFld('page_is_redirect', 0); |
— | — | @@ -91,11 +127,16 @@ |
92 | 128 | $plfrm = intval($this->contID); |
93 | 129 | if ($this->contLevel == 0) { |
94 | 130 | // For the first level, there is only one target title, so no need for complex filtering |
95 | | - $this->addWhere("pl_from>=$plfrm"); |
| 131 | + $this->addWhere($this->bl_from . '>=' . $plfrm); |
96 | 132 | } else { |
97 | 133 | $ns = $this->contTitle->getNamespace(); |
98 | 134 | $t = $db->addQuotes($this->contTitle->getDBkey()); |
99 | | - $this->addWhere("(pl_namespace>$ns OR (pl_namespace=$ns AND (pl_title>$t OR (pl_title=$t AND pl_from>=$plfrm))))"); |
| 135 | + $whereWithoutNS = "{$this->bl_title}>$t OR ({$this->bl_title}=$t AND {$this->bl_from}>=$plfrm))"; |
| 136 | + |
| 137 | + if ($this->hasNS) |
| 138 | + $this->addWhere("{$this->bl_ns}>$ns OR ({$this->bl_ns}=$ns AND ($whereWithoutNS)"); |
| 139 | + else |
| 140 | + $this->addWhere($whereWithoutNS); |
100 | 141 | } |
101 | 142 | } |
102 | 143 | |
— | — | @@ -106,7 +147,14 @@ |
107 | 148 | while ($row = $db->fetchObject($res)) { |
108 | 149 | if (++ $count > $limit) { |
109 | 150 | // We've reached the one extra which shows that there are additional pages to be had. Stop here... |
110 | | - $continue = $this->rootTitle->getNamespace() . '|' . $this->rootTitle->getDBkey() . '|1|0|' . $row->pl_namespace . '|' . $row->pl_title . '|' . $row->page_id; |
| 151 | + if ($redirect) { |
| 152 | + $ns = $row-> { |
| 153 | + $this->bl_ns }; |
| 154 | + $t = $row-> { |
| 155 | + $this->bl_title }; |
| 156 | + $continue = $this->getContinueRedirStr(false, 0, $ns, $t, $row->page_id); |
| 157 | + } else |
| 158 | + $continue = $this->getContinueStr($row->page_id); |
111 | 159 | $this->setContinueEnumParameter('continue', $continue); |
112 | 160 | break; |
113 | 161 | } |
— | — | @@ -123,17 +171,17 @@ |
124 | 172 | |
125 | 173 | if (is_null($resultPageSet)) { |
126 | 174 | $result = $this->getResult(); |
127 | | - $result->setIndexedTagName($data, 'bl'); |
| 175 | + $result->setIndexedTagName($data, $this->bl_code); |
128 | 176 | $result->addValue('query', $this->getModuleName(), $data); |
129 | 177 | } |
130 | 178 | } |
131 | 179 | |
132 | 180 | protected function processContinue($continue, $redirect) { |
133 | 181 | $pageSet = $this->getPageSet(); |
134 | | - $count = $pageSet->getGoodTitleCount(); |
| 182 | + $count = $pageSet->getTitleCount(); |
135 | 183 | if (!is_null($continue)) { |
136 | 184 | if ($count !== 0) |
137 | | - $this->dieUsage('When continuing the backlink query, no other titles may be provided', 'titles_on_continue'); |
| 185 | + $this->dieUsage("When continuing the {$this->getModuleName()} query, no other titles may be provided", 'titles_on_continue'); |
138 | 186 | $this->parseContinueParam($continue, $redirect); |
139 | 187 | |
140 | 188 | // Skip all completed links |
— | — | @@ -141,46 +189,61 @@ |
142 | 190 | |
143 | 191 | } else { |
144 | 192 | if ($count !== 1) |
145 | | - $this->dieUsage('Backlinks requires one title to start the query', 'bad_title_count'); |
146 | | - $this->rootTitle = array_pop($pageSet->getGoodTitles()); // only one title there |
| 193 | + $this->dieUsage("The {$this->getModuleName()} query requires one title to start", 'bad_title_count'); |
| 194 | + $this->rootTitle = current($pageSet->getTitles()); // only one title there |
147 | 195 | } |
| 196 | + |
| 197 | + // only image titles are allowed for the root |
| 198 | + if (!$this->hasNS && $this->rootTitle->getNamespace() !== NS_IMAGE) |
| 199 | + $this->dieUsage("The title for {$this->getModuleName()} query must be an image", 'bad_image_title'); |
148 | 200 | } |
149 | 201 | |
150 | 202 | protected function parseContinueParam($continue, $redirect) { |
151 | | - // |
152 | | - // the parameter will be in the format: |
153 | | - // ns|db_key|step|level|ns|db_key |
154 | | - // ns+db_key -- the root title |
155 | | - // step = 1 or 2 - which step to continue from - 1-titles, 2-redirects |
156 | | - // level -- how many levels to follow before starting enumerating. |
157 | | - // ns+title to continue from |
158 | | - // |
159 | 203 | $continueList = explode('|', $continue); |
160 | | - if (count($continueList) === 7) { |
161 | | - $rootNs = intval($continueList[0]); |
162 | | - if (($rootNs !== 0 || $continueList[0] === '0') && !empty ($continueList[1])) { |
163 | | - $this->rootTitle = Title :: makeTitleSafe($rootNs, $continueList[1]); |
164 | | - if ($this->rootTitle && $this->rootTitle->userCanRead()) { |
| 204 | + if ($redirect) { |
| 205 | + // |
| 206 | + // expected redirect-mode parameter: |
| 207 | + // ns|db_key|step|level|ns|db_key|id |
| 208 | + // ns+db_key -- the root title |
| 209 | + // step = 1 or 2 - which step to continue from - 1-titles, 2-redirects |
| 210 | + // level -- how many levels to follow before starting enumerating. |
| 211 | + // if level > 0 -- ns+title to continue from, otherwise skip these |
| 212 | + // id = last page_id to continue from |
| 213 | + // |
| 214 | + if (count($continueList) > 4) { |
| 215 | + $rootNs = intval($continueList[0]); |
| 216 | + if (($rootNs !== 0 || $continueList[0] === '0') && !empty ($continueList[1])) { |
| 217 | + $this->rootTitle = Title :: makeTitleSafe($rootNs, $continueList[1]); |
| 218 | + if ($this->rootTitle && $this->rootTitle->userCanRead()) { |
165 | 219 | |
166 | | - $step = intval($continueList[2]); |
167 | | - if ($step === 1 || $step === 2) { |
168 | | - $this->contRedirs = ($step === 2); |
| 220 | + $step = intval($continueList[2]); |
| 221 | + if ($step === 1 || $step === 2) { |
| 222 | + $this->contRedirs = ($step === 2); |
169 | 223 | |
170 | | - $level = intval($continueList[3]); |
171 | | - if ($level !== 0 || $continueList[3] === '0') { |
172 | | - $this->contLevel = $level; |
| 224 | + $level = intval($continueList[3]); |
| 225 | + if ($level !== 0 || $continueList[3] === '0') { |
| 226 | + $this->contLevel = $level; |
173 | 227 | |
174 | | - $contNs = intval($continueList[4]); |
175 | | - if (($contNs !== 0 || $continueList[4] === '0') && !empty ($continueList[5])) { |
176 | | - $this->contTitle = Title :: makeTitleSafe($contNs, $continueList[5]); |
| 228 | + if ($level === 0) { |
| 229 | + if (count($continueList) === 5) { |
| 230 | + $contID = intval($continueList[4]); |
| 231 | + if ($contID !== 0 || $continueList[4] === '0') { |
| 232 | + $this->contID = $contID; |
| 233 | + return; // done |
| 234 | + } |
| 235 | + } |
| 236 | + } else { |
| 237 | + if (count($continueList) === 7) { |
| 238 | + $contNs = intval($continueList[4]); |
| 239 | + if (($contNs !== 0 || $continueList[4] === '0') && !empty ($continueList[5])) { |
| 240 | + $this->contTitle = Title :: makeTitleSafe($contNs, $continueList[5]); |
177 | 241 | |
178 | | - $contID = intval($continueList[6]); |
179 | | - if ($contID !== 0 || $continueList[6] === '0') { |
180 | | - $this->contID = $contID; |
181 | | - |
182 | | - // When not processing redirects, only page through the non-redirects |
183 | | - if ($redirect || ($step === 1 && $level === 0 && $this->contTitle && $this->contTitle->userCanRead() && $this->contID > 0)) { |
184 | | - return; // done |
| 242 | + $contID = intval($continueList[6]); |
| 243 | + if ($contID !== 0 || $continueList[6] === '0') { |
| 244 | + $this->contID = $contID; |
| 245 | + return; // done |
| 246 | + } |
| 247 | + } |
185 | 248 | } |
186 | 249 | } |
187 | 250 | } |
— | — | @@ -188,11 +251,47 @@ |
189 | 252 | } |
190 | 253 | } |
191 | 254 | } |
| 255 | + } else { |
| 256 | + // |
| 257 | + // expected non-redirect-mode parameter: |
| 258 | + // ns|db_key|id |
| 259 | + // ns+db_key -- the root title |
| 260 | + // id = last page_id to continue from |
| 261 | + // |
| 262 | + if (count($continueList) === 3) { |
| 263 | + $rootNs = intval($continueList[0]); |
| 264 | + if (($rootNs !== 0 || $continueList[0] === '0') && !empty ($continueList[1])) { |
| 265 | + $this->rootTitle = Title :: makeTitleSafe($rootNs, $continueList[1]); |
| 266 | + if ($this->rootTitle && $this->rootTitle->userCanRead()) { |
| 267 | + |
| 268 | + $contID = intval($continueList[2]); |
| 269 | + if ($contID !== 0) { |
| 270 | + $this->contID = $contID; |
| 271 | + return; // done |
| 272 | + } |
| 273 | + } |
| 274 | + } |
| 275 | + } |
192 | 276 | } |
193 | 277 | |
194 | 278 | $this->dieUsage("Invalid continue param. You should pass the original value returned by the previous query", "_badcontinue"); |
195 | 279 | } |
196 | 280 | |
| 281 | + protected function getContinueStr($lastPageID) { |
| 282 | + return $this->rootTitle->getNamespace() . |
| 283 | + '|' . $this->rootTitle->getDBkey() . |
| 284 | + '|' . $lastPageID; |
| 285 | + } |
| 286 | + |
| 287 | + protected function getContinueRedirStr($isRedirPhase, $level, $ns, $title, $lastPageID) { |
| 288 | + return $this->rootTitle->getNamespace() . |
| 289 | + '|' . $this->rootTitle->getDBkey() . |
| 290 | + '|' . ($isRedirPhase ? 1 : 2) . |
| 291 | + '|' . $level . |
| 292 | + ($level > 0 ? ('|' . $ns . '|' . $title) : '') . |
| 293 | + '|' . $lastPageID; |
| 294 | + } |
| 295 | + |
197 | 296 | protected function getAllowedParams() { |
198 | 297 | |
199 | 298 | $namespaces = $this->getQuery()->getValidNamespaces(); |
— | — | @@ -227,12 +326,22 @@ |
228 | 327 | } |
229 | 328 | |
230 | 329 | protected function getExamples() { |
231 | | - return array ( |
232 | | - 'api.php?action=query&list=backlinks&titles=Main%20Page', |
233 | | - 'api.php?action=query&generator=backlinks&titles=Main%20Page&prop=info', |
| 330 | + static $examples = array ( |
| 331 | + 'backlinks' => array ( |
| 332 | + "api.php?action=query&list=backlinks&titles=Main%20Page", |
| 333 | + "api.php?action=query&generator=backlinks&titles=Main%20Page&prop=info" |
| 334 | + ), |
| 335 | + 'embeddedin' => array ( |
| 336 | + "api.php?action=query&list=embeddedin&titles=Template:Stub", |
| 337 | + "api.php?action=query&generator=embeddedin&titles=Template:Stub&prop=info" |
| 338 | + ), |
| 339 | + 'imagelinks' => array ( |
| 340 | + "api.php?action=query&list=imagelinks&titles=Image:Albert%20Einstein%20Head.jpg", |
| 341 | + "api.php?action=query&generator=imagelinks&titles=Image:Albert%20Einstein%20Head.jpg&prop=info" |
| 342 | + ) |
| 343 | + ); |
234 | 344 | |
235 | | - |
236 | | - ); |
| 345 | + return $examples[$this->getModuleName()]; |
237 | 346 | } |
238 | 347 | |
239 | 348 | public function getVersion() { |
Index: trunk/phase3/includes/api/ApiPageSet.php |
— | — | @@ -32,7 +32,7 @@ |
33 | 33 | class ApiPageSet extends ApiQueryBase { |
34 | 34 | |
35 | 35 | private $mAllPages; // [ns][dbkey] => page_id or 0 when missing |
36 | | - private $mGoodTitles, $mMissingTitles, $mMissingPageIDs, $mRedirectTitles, $mNormalizedTitles; |
| 36 | + private $mTitles, $mGoodTitles, $mMissingTitles, $mMissingPageIDs, $mRedirectTitles, $mNormalizedTitles; |
37 | 37 | private $mResolveRedirects, $mPendingRedirectIDs; |
38 | 38 | private $mGoodRevIDs, $mMissingRevIDs; |
39 | 39 | |
— | — | @@ -42,6 +42,7 @@ |
43 | 43 | parent :: __construct($query, __CLASS__); |
44 | 44 | |
45 | 45 | $this->mAllPages = array (); |
| 46 | + $this->mTitles = array(); |
46 | 47 | $this->mGoodTitles = array (); |
47 | 48 | $this->mMissingTitles = array (); |
48 | 49 | $this->mMissingPageIDs = array (); |
— | — | @@ -89,6 +90,21 @@ |
90 | 91 | } |
91 | 92 | |
92 | 93 | /** |
| 94 | + * All Title objects provided. |
| 95 | + * @return array of Title objects |
| 96 | + */ |
| 97 | + public function getTitles() { |
| 98 | + return $this->mTitles; |
| 99 | + } |
| 100 | + |
| 101 | + /** |
| 102 | + * Returns the number of unique pages (not revisions) in the set. |
| 103 | + */ |
| 104 | + public function getTitleCount() { |
| 105 | + return count($this->mTitles); |
| 106 | + } |
| 107 | + |
| 108 | + /** |
93 | 109 | * Title objects that were found in the database. |
94 | 110 | * @return array page_id (int) => Title (obj) |
95 | 111 | */ |
— | — | @@ -97,10 +113,10 @@ |
98 | 114 | } |
99 | 115 | |
100 | 116 | /** |
101 | | - * Returns the number of unique pages (not revisions) in the set. |
| 117 | + * Returns the number of found unique pages (not revisions) in the set. |
102 | 118 | */ |
103 | 119 | public function getGoodTitleCount() { |
104 | | - return count($this->getGoodTitles()); |
| 120 | + return count($this->mGoodTitles); |
105 | 121 | } |
106 | 122 | |
107 | 123 | /** |
— | — | @@ -252,6 +268,7 @@ |
253 | 269 | |
254 | 270 | $pageId = intval($row->page_id); |
255 | 271 | $this->mAllPages[$row->page_namespace][$row->page_title] = $pageId; |
| 272 | + $this->mTitles[] = $title; |
256 | 273 | |
257 | 274 | if ($this->mResolveRedirects && $row->page_is_redirect == '1') { |
258 | 275 | $this->mPendingRedirectIDs[$pageId] = $title; |
— | — | @@ -366,8 +383,10 @@ |
367 | 384 | // The remaining titles in $remaining are non-existant pages |
368 | 385 | foreach ($remaining as $ns => $dbkeys) { |
369 | 386 | foreach ($dbkeys as $dbkey => $nothing) { |
370 | | - $this->mMissingTitles[] = Title :: makeTitle($ns, $dbkey); |
| 387 | + $title = Title :: makeTitle($ns, $dbkey); |
| 388 | + $this->mMissingTitles[] = $title; |
371 | 389 | $this->mAllPages[$ns][$dbkey] = 0; |
| 390 | + $this->mTitles[] = $title; |
372 | 391 | } |
373 | 392 | } |
374 | 393 | } |