Jackmcbarn has uploaded a new change for review.

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

Change subject: Expose argument keys without their values
......................................................................

Expose argument keys without their values

It's possible that some argument values could take a long time to expand,
or their expansions could have side effects. Allow fetching a list of keys
without expanding all of the values.

Change-Id: I63485d24da405a68a02e408142ed2e3b14b4d1d5
---
M includes/parser/Preprocessor.php
M includes/parser/Preprocessor_DOM.php
M includes/parser/Preprocessor_Hash.php
3 files changed, 43 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/03/165103/1

diff --git a/includes/parser/Preprocessor.php b/includes/parser/Preprocessor.php
index b32593c..128c7af 100644
--- a/includes/parser/Preprocessor.php
+++ b/includes/parser/Preprocessor.php
@@ -156,6 +156,12 @@
        public function isEmpty();
 
        /**
+        * Returns all argument keys of this frame
+        * @return array
+        */
+       public function getArgumentKeys();
+
+       /**
         * Returns all arguments of this frame
         * @return array
         */
diff --git a/includes/parser/Preprocessor_DOM.php 
b/includes/parser/Preprocessor_DOM.php
index 2edb79a..f433d41 100644
--- a/includes/parser/Preprocessor_DOM.php
+++ b/includes/parser/Preprocessor_DOM.php
@@ -1454,6 +1454,13 @@
        /**
         * @return array
         */
+       public function getArgumentKeys() {
+               return array();
+       }
+
+       /**
+        * @return array
+        */
        public function getArguments() {
                return array();
        }
@@ -1639,6 +1646,16 @@
                return !count( $this->numberedArgs ) && !count( 
$this->namedArgs );
        }
 
+       public function getArgumentKeys() {
+               $argumentKeys = array();
+               foreach ( array_merge(
+                               array_keys( $this->numberedArgs ),
+                               array_keys( $this->namedArgs ) ) as $key ) {
+                       $argumentKeys[$key] = true;
+               }
+               return $argumentKeys;
+       }
+
        public function getArguments() {
                $arguments = array();
                foreach ( array_merge(
diff --git a/includes/parser/Preprocessor_Hash.php 
b/includes/parser/Preprocessor_Hash.php
index 6376396..ef80154 100644
--- a/includes/parser/Preprocessor_Hash.php
+++ b/includes/parser/Preprocessor_Hash.php
@@ -1367,6 +1367,13 @@
        /**
         * @return array
         */
+       public function getArgumentKeys() {
+               return array();
+       }
+
+       /**
+        * @return array
+        */
        public function getArguments() {
                return array();
        }
@@ -1555,6 +1562,19 @@
        /**
         * @return array
         */
+       public function getArgumentKeys() {
+               $argumentKeys = array();
+               foreach ( array_merge(
+                               array_keys( $this->numberedArgs ),
+                               array_keys( $this->namedArgs ) ) as $key ) {
+                       $argumentKeys[$key] = true;
+               }
+               return $argumentKeys;
+       }
+
+       /**
+        * @return array
+        */
        public function getArguments() {
                $arguments = array();
                foreach ( array_merge(

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I63485d24da405a68a02e408142ed2e3b14b4d1d5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Jackmcbarn <jackmcb...@gmail.com>

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

Reply via email to