Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Didn't check return value of select #17

Closed
wants to merge 2 commits into from

3 participants

Mark A. Hershberger Sam Reed Brandon Savage
Mark A. Hershberger

select can return false.

Brandon Savage

You can test for false.

if ($res === false)

Note the three equals signs. This tests for type and value equality.

Yes, but an db object won't evaluate as false, so this is safe. I've nothing against the === operator if you prefer that, though.

Sam Reed
 * @return ResultWrapper. If the query returned no rows, a ResultWrapper
 *   with no rows in it will be returned. If there was a query error, a
 *   DBQueryError exception will be thrown, except if the "ignore errors"
 *   option was set, in which case false will be returned.

For MediaWiki usage, you're really only going to get a ResultWrapper object or false. If it throws an exception we don't care what the return value is anyway

Brandon Savage

Cannot be automatically merged. r- until resubmitted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 1 deletion.
  1. +1 −1  cache.sql
  2. +5 −0 cache/BugzillaCacheMysql.class.php
2  cache.sql
View
@@ -7,4 +7,4 @@ CREATE TABLE IF NOT EXISTS `bugzilla_cache` (
PRIMARY KEY (`id`)
) ENGINE=InnoDB, DEFAULT CHARSET=binary;
-CREATE UNIQUE INDEX `key_unique` ON `bugzilla_cache` (`key`);
+CREATE UNIQUE INDEX `uniq_bugzilla_cache_key` ON `bugzilla_cache` (`key`);
5 cache/BugzillaCacheMysql.class.php
View
@@ -55,6 +55,11 @@ public function get($key)
'LIMIT' => 1)
);
+ if( !$res ) {
+ $this->expire( $key );
+ return;
+ }
+
$row = $res->fetchRow();
if(!$row || ($row['expires'] < time())) {
Something went wrong with that request. Please try again.