Replace misplaced strlen() checks with strict `false` comparisons
authorThiemo Kreuz <thiemo.kreuz@wikimedia.de>
Wed, 27 Mar 2019 10:10:39 +0000 (11:10 +0100)
committerThiemo Kreuz <thiemo.kreuz@wikimedia.de>
Wed, 27 Mar 2019 10:10:39 +0000 (11:10 +0100)
As far as I can tell the intention of this code is *not* to detect
empty strings, but `false`.

Change-Id: I406d065a54a1437fdfd46827fec9493e5fad05f9

includes/externalstore/ExternalStore.php
includes/libs/rdbms/database/Database.php

index de7d1a4..9cf8e15 100644 (file)
@@ -197,7 +197,7 @@ class ExternalStore {
                                        $msg = 'read only';
                                } else {
                                        $url = $store->store( $path, $data );
-                                       if ( strlen( $url ) ) {
+                                       if ( $url !== false ) {
                                                return $url; // a store accepted the write; done!
                                        }
                                        $msg = 'operation failed';
index dea7aab..fcd15f1 100644 (file)
@@ -2547,7 +2547,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
                        throw new InvalidArgumentException( "Table must be a string or Subquery." );
                }
 
-               if ( !strlen( $alias ) || $alias === $table ) {
+               if ( $alias === false || $alias === $table ) {
                        if ( $table instanceof Subquery ) {
                                throw new InvalidArgumentException( "Subquery table missing alias." );
                        }