Pastakhov has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/382180 )

Change subject: Fix dump function (v 3.8.1)
......................................................................

Fix dump function (v 3.8.1)

Change-Id: I475bccd75a751390844eada6bd16effaabc58035
---
M extension.json
M includes/PhpTagsFunc.php
2 files changed, 23 insertions(+), 2 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/PhpTagsFunctions 
refs/changes/80/382180/1

diff --git a/extension.json b/extension.json
index 523e342..420985d 100644
--- a/extension.json
+++ b/extension.json
@@ -1,6 +1,6 @@
 {
        "name": "PhpTags Functions",
-       "version": "3.8",
+       "version": "3.8.1",
        "author": "[https://www.mediawiki.org/wiki/User:Pastakhov Pavel 
Astakhov]",
        "url": "https://www.mediawiki.org/wiki/Extension:PhpTags_Functions";,
        "descriptionmsg": "phptagsfunctions-desc",
@@ -27,5 +27,9 @@
        "ParserTestFiles": [
                "tests/parser/PhpTagsFunctionsTests.txt"
        ],
+       "config": {
+               "PhpTagsFunctionDumpDepth": 2,
+               "PhpTagsFunctionDumpAmount": 10
+       },
        "manifest_version": 1
 }
diff --git a/includes/PhpTagsFunc.php b/includes/PhpTagsFunc.php
index 75fee61..dbcf891 100644
--- a/includes/PhpTagsFunc.php
+++ b/includes/PhpTagsFunc.php
@@ -138,13 +138,30 @@
                return $return ? $ret : new \PhpTags\outPrint( true, $ret );
        }
 
-       private static function getValidDumpValue( $expression ) {
+       private static function getValidDumpValue( $expression, $arrayDepth = 0 
) {
+               global $wgPhpTagsFunctionDumpDepth, 
$wgPhpTagsFunctionDumpAmount;
+
                if ( is_object( $expression ) ) {
                        if ( $expression instanceof \PhpTags\GenericObject ) {
                                return (array)$expression->getDumpValue();
                        } else {
                                throw new PhpTagsException( 
PhpTagsException::FATAL_INTERNAL_ERROR );
                        }
+               } else if ( is_array( $expression ) ) {
+                       if ( $arrayDepth >= $wgPhpTagsFunctionDumpDepth ) {
+                               return '... Depth limit reached ...';
+                       }
+                       $return = [];
+                       $n = 0;
+                       foreach ( $expression as $key => $e ) {
+                               if ( $n >= $wgPhpTagsFunctionDumpAmount ) {
+                                       $return[ $key ] = '... Amount limit 
reached ...';
+                                       break;
+                               }
+                               $n++;
+                               $return[ $key ] = self::getValidDumpValue( $e, 
$arrayDepth + 1 );
+                       }
+                       return $return;
                }
                return $expression;
        }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I475bccd75a751390844eada6bd16effaabc58035
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/PhpTagsFunctions
Gerrit-Branch: master
Gerrit-Owner: Pastakhov <[email protected]>

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

Reply via email to