Index: trunk/phase3/includes/api/ApiQueryBase.php |
— | — | @@ -324,14 +324,10 @@ |
325 | 325 | * @return string Page title with underscores |
326 | 326 | */ |
327 | 327 | public function titleToKey($title) { |
| 328 | + # Don't throw an error if we got an empty string |
| 329 | + if(trim($title) == '') return ''; |
328 | 330 | $t = Title::newFromText($title); |
329 | | - if(!$t) |
330 | | - { |
331 | | - # Don't throw an error if we got an empty string |
332 | | - if($title == '') |
333 | | - return ''; |
334 | | - $this->dieUsageMsg(array('invalidtitle', $title)); |
335 | | - } |
| 331 | + if(!$t) $this->dieUsageMsg(array('invalidtitle', $title)); |
336 | 332 | return $t->getDbKey(); |
337 | 333 | } |
338 | 334 | |
— | — | @@ -341,15 +337,11 @@ |
342 | 338 | * @return string Page title with spaces |
343 | 339 | */ |
344 | 340 | public function keyToTitle($key) { |
| 341 | + # Don't throw an error if we got an empty string |
| 342 | + if(trim($key) == '') return ''; |
345 | 343 | $t = Title::newFromDbKey($key); |
346 | 344 | # This really shouldn't happen but we gotta check anyway |
347 | | - if(!$t) |
348 | | - { |
349 | | - # Don't throw an error if we got an empty string |
350 | | - if($key == '') |
351 | | - return ''; |
352 | | - $this->dieUsageMsg(array('invalidtitle', $key)); |
353 | | - } |
| 345 | + if(!$t) $this->dieUsageMsg(array('invalidtitle', $key)); |
354 | 346 | return $t->getPrefixedText(); |
355 | 347 | } |
356 | 348 | |