MarkAHershberger has uploaded a new change for review.

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


Change subject: Initial attempt at backporting
......................................................................

Initial attempt at backporting

Change-Id: Ia42d52e9545d7f03c63ff5d7af3f112588e54b94
---
M common/Hooks.php
M engines/LuaCommon/SiteLibrary.php
M engines/LuaCommon/TitleLibrary.php
3 files changed, 37 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Scribunto 
refs/changes/33/75133/1

diff --git a/common/Hooks.php b/common/Hooks.php
index 0186477..6f5a98b 100644
--- a/common/Hooks.php
+++ b/common/Hooks.php
@@ -48,7 +48,7 @@
 
        /**
         * Called when the interpreter is to be reset.
-        * 
+        *
         * @param $parser Parser
         * @return bool
         */
@@ -79,9 +79,9 @@
         * @return string
         */
        public static function invokeHook( &$parser, $frame, $args ) {
-               if ( !@constant( get_class( $frame ) . 
'::SUPPORTS_INDEX_OFFSET' ) ) {
-                       throw new MWException( 
-                               'Scribunto needs MediaWiki 1.20 or later 
(Preprocessor::SUPPORTS_INDEX_OFFSET)' );
+               if ( @constant( get_class( $frame ) . '::SUPPORTS_INDEX_OFFSET' 
) ) {
+                       throw new MWException(
+                               'This version of Scribunto was adapted for 
1.19.  You should upgrade Scribunto.' );
                }
 
                wfProfileIn( __METHOD__ );
@@ -104,6 +104,8 @@
 
                        unset( $args[0] );
                        unset( $args[1] );
+                       // No idea if this is right, but it WFM! -- mah 
2013-07-22
+                       if (isset($args[2])) { $args = $args[2]; }
                        $childFrame = $frame->newChild( $args, $title, 1 );
                        $result = $module->invoke( $functionName, $childFrame );
                        $result = UtfNormal::cleanUp( strval( $result ) );
@@ -133,7 +135,7 @@
                        wfProfileOut( __METHOD__ );
 
                        // #iferror-compatible error element
-                       return "<strong class=\"error\"><span 
class=\"scribunto-error\" id=\"$id\">" . 
+                       return "<strong class=\"error\"><span 
class=\"scribunto-error\" id=\"$id\">" .
                                $parserError. "</span></strong>";
                }
        }
@@ -154,7 +156,7 @@
                                return false;
                        }
                }
-               
+
                return true;
        }
 
@@ -174,7 +176,7 @@
 
        /**
         * Adds report of number of evaluations by the single wikitext page.
-        * 
+        *
         * @param $parser Parser
         * @param $report
         * @return bool
@@ -196,7 +198,7 @@
                return true;
        }
 
-       /** 
+       /**
         * EditPageBeforeEditChecks hook
         * @param $editor EditPage
         * @param $checkboxes Checkbox array
@@ -329,7 +331,7 @@
         */
        public static function parserOutputHook( $outputPage, $parserOutput ) {
                $outputPage->addModules( 'ext.scribunto' );
-               $outputPage->addInlineScript( 'mw.loader.using("ext.scribunto", 
function() {' . 
+               $outputPage->addInlineScript( 'mw.loader.using("ext.scribunto", 
function() {' .
                        Xml::encodeJsCall( 'mw.scribunto.setErrors', array( 
$parserOutput->scribunto_errors ) )
                        . '});' );
        }
diff --git a/engines/LuaCommon/SiteLibrary.php 
b/engines/LuaCommon/SiteLibrary.php
index 12dd58b..6c75462 100644
--- a/engines/LuaCommon/SiteLibrary.php
+++ b/engines/LuaCommon/SiteLibrary.php
@@ -4,6 +4,22 @@
        private static $namespacesCache = null;
        private $pagesInCategoryCache = array();
 
+       static function isNonincludable( $index ) {
+               if( method_exists( "MWNamespace", 'isNonincludable' ) ) {
+                       return MWNamespace::isNonincludable( $index );
+               } else {
+                       global $wgNonincludableNamespaces;
+                       return $wgNonincludableNamespaces && in_array( $index, 
$wgNonincludableNamespaces );
+               }
+       }
+
+       static function getNamespaceContentModel( $ns ) {
+               if( method_exists( "MWNamespace", "getNamespaceContentModel" ) 
) {
+                       return MWNamespace::isNonincludable( $index );
+               }
+               return null;
+       }
+
        function register() {
                global $wgContLang, $wgNamespaceAliases, $wgDisableCounters;
 
@@ -34,11 +50,11 @@
                                        'hasGenderDistinction' => 
MWNamespace::hasGenderDistinction( $ns ),
                                        'isCapitalized' => 
MWNamespace::isCapitalized( $ns ),
                                        'isContent' => MWNamespace::isContent( 
$ns ),
-                                       'isIncludable' => 
!MWNamespace::isNonincludable( $ns ),
+                                       'isIncludable' => 
!self::isNonincludable( $ns ),
                                        'isMovable' => MWNamespace::isMovable( 
$ns ),
                                        'isSubject' => MWNamespace::isSubject( 
$ns ),
                                        'isTalk' => MWNamespace::isTalk( $ns ),
-                                       'defaultContentModel' => 
MWNamespace::getNamespaceContentModel( $ns ),
+                                       'defaultContentModel' => 
self::getNamespaceContentModel( $ns ),
                                        'aliases' => array(),
                                );
                                if ( $ns >= NS_MAIN ) {
diff --git a/engines/LuaCommon/TitleLibrary.php 
b/engines/LuaCommon/TitleLibrary.php
index 5125920..a387c54 100644
--- a/engines/LuaCommon/TitleLibrary.php
+++ b/engines/LuaCommon/TitleLibrary.php
@@ -47,6 +47,13 @@
                }
        }
 
+       static function getContentModel( $title ) {
+               if( method_exists( $title, "getContentModel" ) ) {
+                       return $title->getContentModel();
+               }
+               return null;
+       }
+
        /**
         * Extract information from a Title object for return to Lua
         *
@@ -79,7 +86,7 @@
                        'text' => $title->getText(),
                        'id' => $title->getArticleID(),
                        'fragment' => $title->getFragment(),
-                       'contentModel' => $title->getContentModel(),
+                       'contentModel' => self::getContentModel( $title ),
                        'thePartialUrl' => $title->getPartialURL(),
                );
                if ( $ns === NS_SPECIAL ) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia42d52e9545d7f03c63ff5d7af3f112588e54b94
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Scribunto
Gerrit-Branch: master
Gerrit-Owner: MarkAHershberger <[email protected]>

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

Reply via email to