Aude has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/63710


Change subject: (bug 48497) Check for offsetExists in ByPropertyIdArray
......................................................................

(bug 48497) Check for offsetExists in ByPropertyIdArray

Change-Id: I7308c74e7de70b9c43da6f232270d8379ad4704b
---
M lib/includes/ByPropertyIdArray.php
M lib/tests/phpunit/ByPropertyIdArrayTest.php
2 files changed, 5 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/10/63710/2

diff --git a/lib/includes/ByPropertyIdArray.php 
b/lib/includes/ByPropertyIdArray.php
index b5df765..959fca0 100644
--- a/lib/includes/ByPropertyIdArray.php
+++ b/lib/includes/ByPropertyIdArray.php
@@ -91,7 +91,7 @@
         *
         * @param integer $propertyId
         *
-        * @return object[]
+        * @return object[]|null
         * @throws MWException
         */
        public function getByPropertyId( $propertyId ) {
@@ -99,7 +99,7 @@
                        throw new MWException( 'Index not build, call 
buildIndex first' );
                }
 
-               return $this->byId[$propertyId];
+               return array_key_exists( $propertyId, $this->byId ) ? 
$this->byId[$propertyId] : null;
        }
 
 }
diff --git a/lib/tests/phpunit/ByPropertyIdArrayTest.php 
b/lib/tests/phpunit/ByPropertyIdArrayTest.php
index ce18473..482e0d0 100644
--- a/lib/tests/phpunit/ByPropertyIdArrayTest.php
+++ b/lib/tests/phpunit/ByPropertyIdArrayTest.php
@@ -113,6 +113,9 @@
                }
 
                $this->assertArrayEquals( $objects, $allObtainedObjects );
+
+               // test for property not in array
+               $this->assertEquals( null, $indexedArray->getByPropertyId( 2077 
) );
        }
 
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/63710
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7308c74e7de70b9c43da6f232270d8379ad4704b
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Aude <aude.w...@gmail.com>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to