Fix check to see if element is there already.
authorjeroendedauw <jeroendedauw@gmail.com>
Sat, 8 Dec 2012 18:13:44 +0000 (19:13 +0100)
committerjeroendedauw <jeroendedauw@gmail.com>
Sat, 8 Dec 2012 18:13:46 +0000 (19:13 +0100)
PHP docs disagree with reality when it comes to return type of offsetGet, so switching to offsetExists.

Issue spotted by Brad Jorsch

Change-Id: I4ce1651d4ed681ab55cf297090ee963b64584bbf

includes/site/SiteArray.php

index 141629e..ad57ed3 100644 (file)
@@ -86,12 +86,12 @@ class SiteArray extends GenericArrayObject implements SiteList {
         * @param mixed $index
         */
        public function offsetUnset( $index ) {
-               /**
-                * @var Site $site
-                */
-               $site = $this->offsetGet( $index );
+               if ( $this->offsetExists( $index ) ) {
+                       /**
+                        * @var Site $site
+                        */
+                       $site = $this->offsetGet( $index );
 
-               if ( $site !== false ) {
                        unset( $this->byGlobalId[$site->getGlobalId()] );
                        unset( $this->byInternalId[$site->getInternalId()] );
                }