Index: trunk/phase3/includes/api/ApiProtect.php |
— | — | @@ -46,7 +46,7 @@ |
47 | 47 | $this->dieUsageMsg(array('missingparam', 'title')); |
48 | 48 | if(!isset($params['token'])) |
49 | 49 | $this->dieUsageMsg(array('missingparam', 'token')); |
50 | | - if(!isset($params['protections']) || empty($params['protections'])) |
| 50 | + if(empty($params['protections'])) |
51 | 51 | $this->dieUsageMsg(array('missingparam', 'protections')); |
52 | 52 | |
53 | 53 | if(!$wgUser->matchEditToken($params['token'])) |
— | — | @@ -57,7 +57,7 @@ |
58 | 58 | $this->dieUsageMsg(array('invalidtitle', $params['title'])); |
59 | 59 | |
60 | 60 | $errors = $titleObj->getUserPermissionsErrors('protect', $wgUser); |
61 | | - if(!empty($errors)) |
| 61 | + if($errors) |
62 | 62 | // We don't care about multiple errors, just report one of them |
63 | 63 | $this->dieUsageMsg(current($errors)); |
64 | 64 | |
Index: trunk/phase3/includes/api/ApiEditPage.php |
— | — | @@ -68,7 +68,7 @@ |
69 | 69 | $errors = $titleObj->getUserPermissionsErrors('edit', $wgUser); |
70 | 70 | if(!$titleObj->exists()) |
71 | 71 | $errors = array_merge($errors, $titleObj->getUserPermissionsErrors('create', $wgUser)); |
72 | | - if(!empty($errors)) |
| 72 | + if(count($errors)) |
73 | 73 | $this->dieUsageMsg($errors[0]); |
74 | 74 | |
75 | 75 | $articleObj = new Article($titleObj); |
— | — | @@ -145,7 +145,7 @@ |
146 | 146 | $r = array(); |
147 | 147 | if(!wfRunHooks('APIEditBeforeSave', array(&$ep, $ep->textbox1, &$r))) |
148 | 148 | { |
149 | | - if(!empty($r)) |
| 149 | + if(count($r)) |
150 | 150 | { |
151 | 151 | $r['result'] = "Failure"; |
152 | 152 | $this->getResult()->addValue(null, $this->getModuleName(), $r); |
Index: trunk/phase3/includes/api/ApiQueryUserContributions.php |
— | — | @@ -227,7 +227,7 @@ |
228 | 228 | $vals['top'] = ''; |
229 | 229 | } |
230 | 230 | |
231 | | - if ($this->fld_comment && !empty ($row->rev_comment)) |
| 231 | + if ($this->fld_comment && isset( $row->rev_comment ) ) |
232 | 232 | $vals['comment'] = $row->rev_comment; |
233 | 233 | |
234 | 234 | return $vals; |
Index: trunk/phase3/includes/api/ApiQueryUsers.php |
— | — | @@ -68,7 +68,7 @@ |
69 | 69 | else |
70 | 70 | $goodNames[] = $n; |
71 | 71 | } |
72 | | - if(empty($goodNames)) |
| 72 | + if(!count($goodNames)) |
73 | 73 | return $retval; |
74 | 74 | |
75 | 75 | $db = $this->getDb(); |
Index: trunk/phase3/includes/api/ApiBlock.php |
— | — | @@ -88,7 +88,7 @@ |
89 | 89 | |
90 | 90 | $userID = $expiry = null; |
91 | 91 | $retval = $form->doBlock($userID, $expiry); |
92 | | - if(!empty($retval)) |
| 92 | + if(count($retval)) |
93 | 93 | // We don't care about multiple errors, just report one of them |
94 | 94 | $this->dieUsageMsg($retval); |
95 | 95 | |
Index: trunk/phase3/includes/api/ApiQueryRecentChanges.php |
— | — | @@ -100,7 +100,7 @@ |
101 | 101 | $this->addWhereRange('rc_timestamp', $dir, $start, $end); |
102 | 102 | $this->addWhereFld('rc_namespace', $namespace); |
103 | 103 | $this->addWhereFld('rc_deleted', 0); |
104 | | - if(!empty($titles)) |
| 104 | + if($titles) |
105 | 105 | { |
106 | 106 | $lb = new LinkBatch; |
107 | 107 | foreach($titles as $t) |
— | — | @@ -256,7 +256,7 @@ |
257 | 257 | private function extractRowInfo($row) { |
258 | 258 | /* If page was moved somewhere, get the title of the move target. */ |
259 | 259 | $movedToTitle = false; |
260 | | - if (!empty($row->rc_moved_to_title)) |
| 260 | + if (isset($row->rc_moved_to_title) && $row->rc_moved_to_title !== '') |
261 | 261 | $movedToTitle = Title :: makeTitle($row->rc_moved_to_ns, $row->rc_moved_to_title); |
262 | 262 | |
263 | 263 | /* Determine the title of the page that has been changed. */ |
— | — | @@ -320,7 +320,7 @@ |
321 | 321 | $vals['timestamp'] = wfTimestamp(TS_ISO_8601, $row->rc_timestamp); |
322 | 322 | |
323 | 323 | /* Add edit summary / log summary. */ |
324 | | - if ($this->fld_comment && !empty ($row->rc_comment)) { |
| 324 | + if ($this->fld_comment && isset($row->rc_comment)) { |
325 | 325 | $vals['comment'] = $row->rc_comment; |
326 | 326 | } |
327 | 327 | |
Index: trunk/phase3/includes/api/ApiQueryExtLinksUsage.php |
— | — | @@ -54,7 +54,7 @@ |
55 | 55 | |
56 | 56 | // Find the right prefix |
57 | 57 | global $wgUrlProtocols; |
58 | | - if(!is_null($protocol) && !empty($protocol) && !in_array($protocol, $wgUrlProtocols)) |
| 58 | + if($protocol && !in_array($protocol, $wgUrlProtocols)) |
59 | 59 | { |
60 | 60 | foreach ($wgUrlProtocols as $p) { |
61 | 61 | if( substr( $p, 0, strlen( $protocol ) ) === $protocol ) { |
Index: trunk/phase3/includes/api/ApiQueryInfo.php |
— | — | @@ -197,7 +197,7 @@ |
198 | 198 | $pageLength = $pageSet->getCustomField('page_len'); |
199 | 199 | |
200 | 200 | $db = $this->getDB(); |
201 | | - if ($fld_protection && !empty($titles)) { |
| 201 | + if ($fld_protection && count($titles)) { |
202 | 202 | $this->addTables('page_restrictions'); |
203 | 203 | $this->addFields(array('pr_page', 'pr_type', 'pr_level', 'pr_expiry', 'pr_cascade')); |
204 | 204 | $this->addWhereFld('pr_page', array_keys($titles)); |
— | — | @@ -273,7 +273,7 @@ |
274 | 274 | } |
275 | 275 | |
276 | 276 | // We don't need to check for pt stuff if there are no nonexistent titles |
277 | | - if($fld_protection && !empty($missing)) |
| 277 | + if($fld_protection && count($missing)) |
278 | 278 | { |
279 | 279 | $this->resetQueryParams(); |
280 | 280 | // Construct a custom WHERE clause that matches all titles in $missing |
— | — | @@ -367,7 +367,7 @@ |
368 | 368 | else if($fld_talkid) |
369 | 369 | $talktitles[] = $t->getTalkPage(); |
370 | 370 | } |
371 | | - if(!empty($talktitles) || !empty($subjecttitles)) |
| 371 | + if(count($talktitles) || count($subjecttitles)) |
372 | 372 | { |
373 | 373 | // Construct a custom WHERE clause that matches |
374 | 374 | // all titles in $talktitles and $subjecttitles |
Index: trunk/phase3/includes/api/ApiMain.php |
— | — | @@ -590,7 +590,7 @@ |
591 | 591 | |
592 | 592 | public static function makeHelpMsgHeader($module, $paramName) { |
593 | 593 | $modulePrefix = $module->getModulePrefix(); |
594 | | - if (!empty($modulePrefix)) |
| 594 | + if (strval($modulePrefix) !== '') |
595 | 595 | $modulePrefix = "($modulePrefix) "; |
596 | 596 | |
597 | 597 | return "* $paramName={$module->getModuleName()} $modulePrefix*"; |
Index: trunk/phase3/includes/api/ApiQueryBacklinks.php |
— | — | @@ -211,7 +211,7 @@ |
212 | 212 | } |
213 | 213 | $db->freeResult($res); |
214 | 214 | |
215 | | - if($this->redirect && !empty($this->redirTitles)) |
| 215 | + if($this->redirect && count($this->redirTitles)) |
216 | 216 | { |
217 | 217 | $this->resetQueryParams(); |
218 | 218 | $this->prepareSecondQuery($resultPageSet); |
Index: trunk/phase3/includes/api/ApiQuerySearch.php |
— | — | @@ -54,7 +54,7 @@ |
55 | 55 | $limit = $params['limit']; |
56 | 56 | $query = $params['search']; |
57 | 57 | $what = $params['what']; |
58 | | - if (is_null($query) || empty($query)) |
| 58 | + if (strval($query) === '') |
59 | 59 | $this->dieUsage("empty search string is not allowed", 'param-search'); |
60 | 60 | |
61 | 61 | $search = SearchEngine::create(); |
Index: trunk/phase3/includes/api/ApiUnblock.php |
— | — | @@ -69,7 +69,7 @@ |
70 | 70 | $user = $params['user']; |
71 | 71 | $reason = (is_null($params['reason']) ? '' : $params['reason']); |
72 | 72 | $retval = IPUnblockForm::doUnblock($id, $user, $reason, $range); |
73 | | - if(!empty($retval)) |
| 73 | + if($retval) |
74 | 74 | $this->dieUsageMsg($retval); |
75 | 75 | |
76 | 76 | $res['id'] = $id; |
Index: trunk/phase3/includes/api/ApiDelete.php |
— | — | @@ -73,15 +73,15 @@ |
74 | 74 | |
75 | 75 | $reason = (isset($params['reason']) ? $params['reason'] : NULL); |
76 | 76 | if ($titleObj->getNamespace() == NS_IMAGE) { |
77 | | - $retval = self::deletefile($params['token'], $titleObj, $params['oldimage'], $reason, false); |
78 | | - if(!empty($retval)) |
| 77 | + $retval = self::deleteFile($params['token'], $titleObj, $params['oldimage'], $reason, false); |
| 78 | + if(count($retval)) |
79 | 79 | // We don't care about multiple errors, just report one of them |
80 | 80 | $this->dieUsageMsg(current($retval)); |
81 | 81 | } else { |
82 | 82 | $articleObj = new Article($titleObj); |
83 | 83 | $retval = self::delete($articleObj, $params['token'], $reason); |
84 | 84 | |
85 | | - if(!empty($retval)) |
| 85 | + if(count($retval)) |
86 | 86 | // We don't care about multiple errors, just report one of them |
87 | 87 | $this->dieUsageMsg(current($retval)); |
88 | 88 | |
Index: trunk/phase3/includes/api/ApiBase.php |
— | — | @@ -572,7 +572,7 @@ |
573 | 573 | if (is_array($allowedValues)) { |
574 | 574 | # Check for unknown values |
575 | 575 | $unknown = array_diff($valuesList, $allowedValues); |
576 | | - if(!empty($unknown)) |
| 576 | + if(count($unknown)) |
577 | 577 | { |
578 | 578 | if($allowMultiple) |
579 | 579 | { |
Index: trunk/phase3/includes/api/ApiResult.php |
— | — | @@ -100,7 +100,7 @@ |
101 | 101 | } |
102 | 102 | elseif (is_array($arr[$name]) && is_array($value)) { |
103 | 103 | $merged = array_intersect_key($arr[$name], $value); |
104 | | - if (empty ($merged)) |
| 104 | + if (!count($merged)) |
105 | 105 | $arr[$name] += $value; |
106 | 106 | else |
107 | 107 | ApiBase :: dieDebug(__METHOD__, "Attempting to merge element $name"); |
— | — | @@ -180,7 +180,7 @@ |
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
184 | | - if (empty($name)) |
| 184 | + if (!$name) |
185 | 185 | $data[] = $value; // Add list element |
186 | 186 | else |
187 | 187 | ApiResult :: setElement($data, $name, $value); // Add named element |
— | — | @@ -201,7 +201,7 @@ |
202 | 202 | $argc = func_num_args(); |
203 | 203 | |
204 | 204 | if ($argc > 2) { |
205 | | - for ($i = 1; !empty($isec) && $i < $argc; $i++) { |
| 205 | + for ($i = 1; $isec && $i < $argc; $i++) { |
206 | 206 | $arr = func_get_arg($i); |
207 | 207 | |
208 | 208 | foreach (array_keys($isec) as $key) { |
Index: trunk/phase3/includes/api/ApiPageSet.php |
— | — | @@ -368,7 +368,7 @@ |
369 | 369 | } |
370 | 370 | |
371 | 371 | private function initFromPageIds($pageids) { |
372 | | - if(empty($pageids)) |
| 372 | + if(!count($pageids)) |
373 | 373 | return; |
374 | 374 | |
375 | 375 | $pageids = array_map('intval', $pageids); // paranoia |
— | — | @@ -440,7 +440,7 @@ |
441 | 441 | else |
442 | 442 | { |
443 | 443 | // The remaining pageids do not exist |
444 | | - if(empty($this->mMissingPageIDs)) |
| 444 | + if(!$this->mMissingPageIDs) |
445 | 445 | $this->mMissingPageIDs = array_keys($remaining); |
446 | 446 | else |
447 | 447 | $this->mMissingPageIDs = array_merge($this->mMissingPageIDs, array_keys($remaining)); |
— | — | @@ -450,7 +450,7 @@ |
451 | 451 | |
452 | 452 | private function initFromRevIDs($revids) { |
453 | 453 | |
454 | | - if(empty($revids)) |
| 454 | + if(!count($revids)) |
455 | 455 | return; |
456 | 456 | |
457 | 457 | $db = $this->getDB(); |
— | — | @@ -488,7 +488,7 @@ |
489 | 489 | |
490 | 490 | // Repeat until all redirects have been resolved |
491 | 491 | // The infinite loop is prevented by keeping all known pages in $this->mAllPages |
492 | | - while (!empty ($this->mPendingRedirectIDs)) { |
| 492 | + while ($this->mPendingRedirectIDs) { |
493 | 493 | |
494 | 494 | // Resolve redirects by querying the pagelinks table, and repeat the process |
495 | 495 | // Create a new linkBatch object for the next pass |
— | — | @@ -537,7 +537,7 @@ |
538 | 538 | $this->mRedirectTitles[$from] = $to; |
539 | 539 | } |
540 | 540 | $db->freeResult($res); |
541 | | - if(!empty($this->mPendingRedirectIDs)) |
| 541 | + if($this->mPendingRedirectIDs) |
542 | 542 | { |
543 | 543 | # We found pages that aren't in the redirect table |
544 | 544 | # Add them |
— | — | @@ -580,7 +580,7 @@ |
581 | 581 | continue; // There's nothing else we can do |
582 | 582 | } |
583 | 583 | $iw = $titleObj->getInterwiki(); |
584 | | - if (!empty($iw)) { |
| 584 | + if (strval($iw) !== '') { |
585 | 585 | // This title is an interwiki link. |
586 | 586 | $this->mInterwikiTitles[$titleObj->getPrefixedText()] = $iw; |
587 | 587 | } else { |
Index: trunk/phase3/includes/api/ApiQueryLogEvents.php |
— | — | @@ -213,7 +213,7 @@ |
214 | 214 | if ($this->fld_timestamp) { |
215 | 215 | $vals['timestamp'] = wfTimestamp(TS_ISO_8601, $row->log_timestamp); |
216 | 216 | } |
217 | | - if ($this->fld_comment && !empty ($row->log_comment)) { |
| 217 | + if ($this->fld_comment && isset($row->log_comment)) { |
218 | 218 | $vals['comment'] = $row->log_comment; |
219 | 219 | } |
220 | 220 | |
Index: trunk/phase3/includes/api/ApiQueryCategoryInfo.php |
— | — | @@ -41,9 +41,10 @@ |
42 | 42 | |
43 | 43 | public function execute() { |
44 | 44 | $alltitles = $this->getPageSet()->getAllTitlesByNamespace(); |
| 45 | + if ( empty( $alltitles[NS_CATEGORY] ) ) { |
| 46 | + return; |
| 47 | + } |
45 | 48 | $categories = $alltitles[NS_CATEGORY]; |
46 | | - if(empty($categories)) |
47 | | - return; |
48 | 49 | |
49 | 50 | $titles = $this->getPageSet()->getGoodTitles() + |
50 | 51 | $this->getPageSet()->getMissingTitles(); |
Index: trunk/phase3/includes/api/ApiQueryDuplicateFiles.php |
— | — | @@ -50,9 +50,10 @@ |
51 | 51 | private function run($resultPageSet = null) { |
52 | 52 | $params = $this->extractRequestParams(); |
53 | 53 | $namespaces = $this->getPageSet()->getAllTitlesByNamespace(); |
| 54 | + if ( empty( $namespaces[NS_IMAGE] ) ) { |
| 55 | + return; |
| 56 | + } |
54 | 57 | $images = $namespaces[NS_IMAGE]; |
55 | | - if(empty($images)) |
56 | | - return; |
57 | 58 | |
58 | 59 | $this->addTables('image', 'i1'); |
59 | 60 | $this->addTables('image', 'i2'); |
Index: trunk/phase3/includes/api/ApiQueryWatchlist.php |
— | — | @@ -237,7 +237,7 @@ |
238 | 238 | $vals['newlen'] = intval($row->rc_new_len); |
239 | 239 | } |
240 | 240 | |
241 | | - if ($this->fld_comment && !empty ($row->rc_comment)) |
| 241 | + if ($this->fld_comment && isset( $row->rc_comment )) |
242 | 242 | $vals['comment'] = $row->rc_comment; |
243 | 243 | |
244 | 244 | return $vals; |
Index: trunk/phase3/includes/api/ApiRollback.php |
— | — | @@ -66,7 +66,7 @@ |
67 | 67 | $details = null; |
68 | 68 | $retval = $articleObj->doRollback($username, $summary, $params['token'], $params['markbot'], $details); |
69 | 69 | |
70 | | - if(!empty($retval)) |
| 70 | + if($retval) |
71 | 71 | // We don't care about multiple errors, just report one of them |
72 | 72 | $this->dieUsageMsg(current($retval)); |
73 | 73 | |
Index: trunk/phase3/includes/api/ApiPatrol.php |
— | — | @@ -57,7 +57,7 @@ |
58 | 58 | $this->dieUsageMsg(array('nosuchrcid', $params['rcid'])); |
59 | 59 | $retval = RecentChange::markPatrolled($params['rcid']); |
60 | 60 | |
61 | | - if(!empty($retval)) |
| 61 | + if($retval) |
62 | 62 | $this->dieUsageMsg(current($retval)); |
63 | 63 | |
64 | 64 | $result = array('rcid' => $rc->getAttribute('rc_id')); |
Index: trunk/phase3/includes/api/ApiQuery.php |
— | — | @@ -256,7 +256,7 @@ |
257 | 257 | ); |
258 | 258 | } |
259 | 259 | |
260 | | - if (!empty ($normValues)) { |
| 260 | + if (count($normValues)) { |
261 | 261 | $result->setIndexedTagName($normValues, 'n'); |
262 | 262 | $result->addValue('query', 'normalized', $normValues); |
263 | 263 | } |
— | — | @@ -270,7 +270,7 @@ |
271 | 271 | ); |
272 | 272 | } |
273 | 273 | |
274 | | - if (!empty ($intrwValues)) { |
| 274 | + if (count($intrwValues)) { |
275 | 275 | $result->setIndexedTagName($intrwValues, 'i'); |
276 | 276 | $result->addValue('query', 'interwiki', $intrwValues); |
277 | 277 | } |
— | — | @@ -284,7 +284,7 @@ |
285 | 285 | ); |
286 | 286 | } |
287 | 287 | |
288 | | - if (!empty ($redirValues)) { |
| 288 | + if (count($redirValues)) { |
289 | 289 | $result->setIndexedTagName($redirValues, 'r'); |
290 | 290 | $result->addValue('query', 'redirects', $redirValues); |
291 | 291 | } |
— | — | @@ -293,7 +293,7 @@ |
294 | 294 | // Missing revision elements |
295 | 295 | // |
296 | 296 | $missingRevIDs = $pageSet->getMissingRevisionIDs(); |
297 | | - if (!empty ($missingRevIDs)) { |
| 297 | + if (count($missingRevIDs)) { |
298 | 298 | $revids = array (); |
299 | 299 | foreach ($missingRevIDs as $revid) { |
300 | 300 | $revids[$revid] = array ( |
— | — | @@ -335,7 +335,7 @@ |
336 | 336 | $pages[$pageid] = $vals; |
337 | 337 | } |
338 | 338 | |
339 | | - if (!empty ($pages)) { |
| 339 | + if (count($pages)) { |
340 | 340 | |
341 | 341 | if ($this->params['indexpageids']) { |
342 | 342 | $pageIDs = array_keys($pages); |
Index: trunk/phase3/includes/api/ApiQueryRevisions.php |
— | — | @@ -288,7 +288,7 @@ |
289 | 289 | |
290 | 290 | if ($this->fld_comment) { |
291 | 291 | $comment = $revision->getComment(); |
292 | | - if (!empty($comment)) |
| 292 | + if (strval($comment) !== '') |
293 | 293 | $vals['comment'] = $comment; |
294 | 294 | } |
295 | 295 | |
Index: trunk/phase3/includes/api/ApiFormatXml.php |
— | — | @@ -114,15 +114,15 @@ |
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
118 | | - if (is_null($subElemIndName) && !empty ($indElements)) |
| 118 | + if (is_null($subElemIndName) && count($indElements)) |
119 | 119 | ApiBase :: dieDebug(__METHOD__, "($elemName, ...) has integer keys without _element value. Use ApiResult::setIndexedTagName()."); |
120 | 120 | |
121 | | - if (!empty ($subElements) && !empty ($indElements) && !is_null($subElemContent)) |
| 121 | + if (count($subElements) && count($indElements) && !is_null($subElemContent)) |
122 | 122 | ApiBase :: dieDebug(__METHOD__, "($elemName, ...) has content and subelements"); |
123 | 123 | |
124 | 124 | if (!is_null($subElemContent)) { |
125 | 125 | $this->printText($indstr . wfElement($elemName, $elemValue, $subElemContent)); |
126 | | - } elseif (empty ($indElements) && empty ($subElements)) { |
| 126 | + } elseif (!count($indElements) && !count($subElements)) { |
127 | 127 | $this->printText($indstr . wfElement($elemName, $elemValue)); |
128 | 128 | } else { |
129 | 129 | $this->printText($indstr . wfElement($elemName, $elemValue, null)); |