Kaldari has uploaded a new change for review.

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

Change subject: Adding ability to retrieve all the ExtensionData at once
......................................................................

Adding ability to retrieve all the ExtensionData at once

Previously you could only retrieve one piece of the ExtensionData at
a time by specifying a key. This change let's you retrieve all of it
at once.

Includes unit test.

Bug: T121124
Change-Id: I4244b63724448e8159e33d9af2f98821968e404f
---
M includes/parser/ParserOutput.php
M tests/phpunit/includes/parser/ParserOutputTest.php
2 files changed, 14 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/81/258181/1

diff --git a/includes/parser/ParserOutput.php b/includes/parser/ParserOutput.php
index e4c287a..5d71126 100644
--- a/includes/parser/ParserOutput.php
+++ b/includes/parser/ParserOutput.php
@@ -967,14 +967,19 @@
         *
         * @since 1.21
         *
-        * @param string $key The key to look up.
+        * @param string $key [optional] The key to look up.
         *
-        * @return mixed|null The value previously set for the given key using 
setExtensionData()
-        *         or null if no value was set for this key.
+        * @return mixed|null If a key is specified, the value previously set 
for the given
+        *         key using setExtensionData() or null if no value was set for 
this key. If
+        *         no key is specified, the entire mExtensionData array.
         */
-       public function getExtensionData( $key ) {
-               if ( isset( $this->mExtensionData[$key] ) ) {
-                       return $this->mExtensionData[$key];
+       public function getExtensionData( $key = null ) {
+               if ( $key ) {
+                       if ( isset( $this->mExtensionData[$key] ) ) {
+                               return $this->mExtensionData[$key];
+                       }
+               } else {
+                       return $this->mExtensionData;
                }
 
                return null;
diff --git a/tests/phpunit/includes/parser/ParserOutputTest.php 
b/tests/phpunit/includes/parser/ParserOutputTest.php
index e660e09..a83af71 100644
--- a/tests/phpunit/includes/parser/ParserOutputTest.php
+++ b/tests/phpunit/includes/parser/ParserOutputTest.php
@@ -59,6 +59,9 @@
                $po->setExtensionData( "one", null );
                $this->assertNull( $po->getExtensionData( "one" ) );
                $this->assertEquals( "Bar", $po->getExtensionData( "two" ) );
+
+               $this->assertArrayHasKey( "one", $po->getExtensionData() );
+               $this->assertArrayHasKey( "two", $po->getExtensionData() );
        }
 
        /**

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4244b63724448e8159e33d9af2f98821968e404f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Kaldari <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to