jenkins-bot has submitted this change and it was merged. Change subject: Modify function transclude, incompatible! (v 3.6.0) requires PhpTags 1.6.0 ......................................................................
Modify function transclude, incompatible! (v 3.6.0) requires PhpTags 1.6.0 Add the fourth parameter $return Change-Id: Iabb282c55454e2112e07413f4456b2597a306c8c --- M PhpTagsFunctions.hooks.php M PhpTagsFunctions.json M PhpTagsFunctions.php M includes/PhpTagsFuncUseful.php M tests/parser/PhpTagsFunctionsTests.txt 5 files changed, 49 insertions(+), 10 deletions(-) Approvals: Pastakhov: Looks good to me, approved jenkins-bot: Verified diff --git a/PhpTagsFunctions.hooks.php b/PhpTagsFunctions.hooks.php index 9e4b08b..c927053 100644 --- a/PhpTagsFunctions.hooks.php +++ b/PhpTagsFunctions.hooks.php @@ -19,7 +19,7 @@ if ( !defined( 'PHPTAGS_VERSION' ) ) { throw new MWException( "\n\nYou need to have the PhpTags extension installed in order to use the PhpTags Functions extension." ); } - $needVersion = '5.2.0'; + $needVersion = '5.6.0'; if ( version_compare( PHPTAGS_VERSION, $needVersion, '<' ) ) { throw new MWException( "\n\nThis version of the PhpTags Functions extension requires the PhpTags extension $needVersion or above.\n You have " . PHPTAGS_VERSION . ". Please update it." ); } diff --git a/PhpTagsFunctions.json b/PhpTagsFunctions.json index c367881..d8d5563 100644 --- a/PhpTagsFunctions.json +++ b/PhpTagsFunctions.json @@ -2960,7 +2960,8 @@ "parameters": [ { "type": "mixed", "name": "title" }, { "type": "array", "name": "parameters", "default": "array()" }, - { "type": "mixed", "name": "default", "default": "null" } + { "type": "mixed", "name": "default", "default": "null" }, + { "type": "bool", "name": "return", "default": "false" } ], "onfailure": "false", "return": "string", diff --git a/PhpTagsFunctions.php b/PhpTagsFunctions.php index de87312..d458b6a 100644 --- a/PhpTagsFunctions.php +++ b/PhpTagsFunctions.php @@ -15,7 +15,7 @@ die( 'This file is an extension to MediaWiki and thus not a valid entry point.' ); } -const PHPTAGS_FUNCTIONS_VERSION = '3.5.3'; +const PHPTAGS_FUNCTIONS_VERSION = '3.6.0'; // Register this extension on Special:Version $wgExtensionCredits['phptags'][] = array( diff --git a/includes/PhpTagsFuncUseful.php b/includes/PhpTagsFuncUseful.php index 30f64f1..9c49947 100644 --- a/includes/PhpTagsFuncUseful.php +++ b/includes/PhpTagsFuncUseful.php @@ -51,7 +51,7 @@ return $variables['argc'] - 1; } - public static function f_transclude( $template, $parameters = array(), $default = null ) { + public static function f_transclude( $template, $parameters = array(), $default = null, $return = false ) { $parser = \PhpTags\Renderer::getParser(); $frame = \PhpTags\Renderer::getFrame(); if ( $frame->depth >= $parser->mOptions->getMaxTemplateDepth() ) { @@ -96,7 +96,14 @@ $fargs = $parser->getPreprocessor()->newPartNodeArray( $parameters ); $newFrame = $frame->newChild( $fargs, $finalTitle, -1 ); - return $newFrame->expand( $dom ); + $strip = $newFrame->expand( $dom ); + if ( $return ) { + if ( defined( 'PHPTAGS_WIDGETS_VERSION' ) && version_compare( PHPTAGS_WIDGETS_VERSION, '1.6.0', '<' ) ) { + throw new \PhpTags\HookException( 'You cannot use this function for return value while using PhpTags Widgets until version 1.6.0.', \PhpTags\HookException::EXCEPTION_FATAL ); + } + return $parser->mStripState->unstripGeneral( $strip ); + } + return new \PhpTags\outStrip( true, $strip ); } } diff --git a/tests/parser/PhpTagsFunctionsTests.txt b/tests/parser/PhpTagsFunctionsTests.txt index 44f6c58..231c5c1 100644 --- a/tests/parser/PhpTagsFunctionsTests.txt +++ b/tests/parser/PhpTagsFunctionsTests.txt @@ -44,12 +44,45 @@ <phptag> echo "Hello\n\n"; $foo = transclude( "Echo", ['1', '22', '333', '4444'] ); -echo $foo; +echo "\n\n$foo"; echo "\n\nBye"; </phptag> !! result <p>Hello </p><p>1223334444 +</p><p>1 +</p><p>Bye +</p> +!! end + +!! test +Transclude Echo2 +!! input +<phptag> +echo "Hello\n\n"; +$foo = transclude( "Echo", ['1', '22', '333', '4444'], null, true ); +echo "\n\nBye"; +echo "\n\n$foo"; +</phptag> +!! result +<p>Hello +</p><p><br /> +</p><p>Bye +</p><p>1223334444 +</p> +!! end + +!! test +Transclude Echo3 +!! input +<phptag> +echo "Hello\n\n"; +transclude( "Echo", ['1', '22', '333', '4444'], null, true ); +echo "\n\nBye"; +</phptag> +!! result +<p>Hello +</p><p><br /> </p><p>Bye </p> !! end @@ -59,8 +92,7 @@ !! input <phptag> echo "Hello\n\n"; -$foo = transclude( "Dump", ['1', '22', '333', '4444', 'test'=>'TEST'] ); -echo $foo; +transclude( "Dump", ['1', '22', '333', '4444', 'test'=>'TEST'] ); echo "\n\nBye"; </phptag> !! result @@ -83,8 +115,7 @@ !! text <phptag> echo "Hello\n\n"; -$foo = transclude( ":Transclude Loop", ['1', '22', '333', '4444', 'test'=>'TEST'] ); -echo $foo; +transclude( ":Transclude Loop", ['1', '22', '333', '4444', 'test'=>'TEST'] ); echo "\n\nBye"; </phptag> !! endarticle -- To view, visit https://gerrit.wikimedia.org/r/254810 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Iabb282c55454e2112e07413f4456b2597a306c8c Gerrit-PatchSet: 4 Gerrit-Project: mediawiki/extensions/PhpTagsFunctions Gerrit-Branch: master Gerrit-Owner: Pastakhov <pastak...@yandex.ru> Gerrit-Reviewer: Pastakhov <pastak...@yandex.ru> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits