Krinkle has uploaded a new change for review.

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

Change subject: content: Recognise .json as JsonContent User and MediaWiki 
namespace
......................................................................

content: Recognise .json as JsonContent User and MediaWiki namespace

Bug: T76554
Change-Id: I45200f4651d7200cfad541cdd21cc625c711e81f
---
M includes/content/ContentHandler.php
1 file changed, 12 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/72/177172/1

diff --git a/includes/content/ContentHandler.php 
b/includes/content/ContentHandler.php
index ac41722..f10b9f5 100644
--- a/includes/content/ContentHandler.php
+++ b/includes/content/ContentHandler.php
@@ -207,26 +207,26 @@
                        }
                }
 
-               // Could this page contain custom CSS or JavaScript, based on 
the title?
-               $isCssOrJsPage = NS_MEDIAWIKI == $ns && preg_match( 
'!\.(css|js)$!u', $title->getText(), $m );
-               if ( $isCssOrJsPage ) {
+               // Could this page contain code based on the title?
+               $isCodePage = NS_MEDIAWIKI == $ns && preg_match( 
'!\.(css|js|json)$!u', $title->getText(), $m );
+               if ( $isCodePage ) {
                        $ext = $m[1];
                }
 
                // Hook can force JS/CSS
-               wfRunHooks( 'TitleIsCssOrJsPage', array( $title, 
&$isCssOrJsPage ) );
+               wfRunHooks( 'TitleIsCssOrJsPage', array( $title, &$isCodePage ) 
);
 
-               // Is this a .css subpage of a user page?
-               $isJsCssSubpage = NS_USER == $ns
-                       && !$isCssOrJsPage
-                       && preg_match( "/\\/.*\\.(js|css)$/", 
$title->getText(), $m );
-               if ( $isJsCssSubpage ) {
+               // Is this a user subpage containing code?
+               $isCodeSubpage = NS_USER == $ns
+                       && !$isCodePage
+                       && preg_match( "/\\/.*\\.(js|css|json)$/", 
$title->getText(), $m );
+               if ( $isCodeSubpage ) {
                        $ext = $m[1];
                }
 
                // Is this wikitext, according to $wgNamespaceContentModels or 
the DefaultModelFor hook?
                $isWikitext = is_null( $model ) || $model == 
CONTENT_MODEL_WIKITEXT;
-               $isWikitext = $isWikitext && !$isCssOrJsPage && 
!$isJsCssSubpage;
+               $isWikitext = $isWikitext && !$isCodePage && !$isCodeSubpage;
 
                // Hook can override $isWikitext
                wfRunHooks( 'TitleIsWikitextPage', array( $title, &$isWikitext 
) );
@@ -237,6 +237,8 @@
                                        return CONTENT_MODEL_JAVASCRIPT;
                                case 'css':
                                        return CONTENT_MODEL_CSS;
+                               case 'json':
+                                       return CONTENT_MODEL_JSON;
                                default:
                                        return is_null( $model ) ? 
CONTENT_MODEL_TEXT : $model;
                        }

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

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

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

Reply via email to