jenkins-bot has submitted this change and it was merged.

Change subject: Avoid file glob in 
SyntaxHighlight_GeSHi::getSupportedLanguages()
......................................................................


Avoid file glob in SyntaxHighlight_GeSHi::getSupportedLanguages()

Store the list of supported languages in SyntaxHighlight_GeSHi.langs.php, which
is auto-generated via a maintenance script, updateLanguageList.php.

Change-Id: Ie0be7c42fa6716555c3e03e3f28734d7e0302664
---
M README
M SyntaxHighlight_GeSHi.class.php
A SyntaxHighlight_GeSHi.langs.php
M SyntaxHighlight_GeSHi.php
A maintenance/updateLanguageList.php
5 files changed, 280 insertions(+), 9 deletions(-)

Approvals:
  Ori.livneh: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/README b/README
index 3190876..b6af55c 100644
--- a/README
+++ b/README
@@ -50,3 +50,9 @@
 code can easily generate enough of them to crash a browser. As a guard, symbol
 highlighting is turned off for code fragments larger than 100 kB. For fragments
 larger than 200 kB, string highlighting is turned off as well.
+
+== Note to maintainers ==
+
+Whenever updating the version of GeSHi embedded in the extension, run
+maintenance/updateLanguageList.php to re-generate the list of supported
+languages.
diff --git a/SyntaxHighlight_GeSHi.class.php b/SyntaxHighlight_GeSHi.class.php
index 7ac0611..21c7d04 100644
--- a/SyntaxHighlight_GeSHi.class.php
+++ b/SyntaxHighlight_GeSHi.class.php
@@ -482,15 +482,8 @@
         * @return array
         */
        private static function getSupportedLanguages() {
-               if( !is_array( self::$languages ) ) {
-                       self::initialise();
-                       self::$languages = array();
-                       foreach( glob( GESHI_LANG_ROOT . "/*.php" ) as $file ) {
-                               self::$languages[] = basename( $file, '.php' );
-                       }
-                       sort( self::$languages );
-               }
-               return self::$languages;
+               global $wgGeSHiSupportedLanguages;
+               return $wgGeSHiSupportedLanguages;
        }
 
        /**
diff --git a/SyntaxHighlight_GeSHi.langs.php b/SyntaxHighlight_GeSHi.langs.php
new file mode 100644
index 0000000..ff634ae
--- /dev/null
+++ b/SyntaxHighlight_GeSHi.langs.php
@@ -0,0 +1,219 @@
+<?php
+// Generated by updateLanguageList.php on Wed, 19 Nov 2014 00:27:50 +0000
+$wgGeSHiSupportedLanguages = array(
+       "4cs",
+       "6502acme",
+       "6502kickass",
+       "6502tasm",
+       "68000devpac",
+       "abap",
+       "actionscript",
+       "actionscript3",
+       "ada",
+       "algol68",
+       "apache",
+       "applescript",
+       "arm",
+       "asm",
+       "asp",
+       "asymptote",
+       "autoconf",
+       "autohotkey",
+       "autoit",
+       "avisynth",
+       "awk",
+       "bascomavr",
+       "bash",
+       "basic4gl",
+       "bf",
+       "bibtex",
+       "blitzbasic",
+       "bnf",
+       "boo",
+       "c",
+       "caddcl",
+       "cadlisp",
+       "cfdg",
+       "cfm",
+       "chaiscript",
+       "cil",
+       "clojure",
+       "cmake",
+       "cobol",
+       "coffeescript",
+       "cpp",
+       "csharp",
+       "css",
+       "cuesheet",
+       "d",
+       "dcl",
+       "dcpu16",
+       "dcs",
+       "delphi",
+       "diff",
+       "div",
+       "dos",
+       "dot",
+       "e",
+       "ecmascript",
+       "eiffel",
+       "email",
+       "epc",
+       "erlang",
+       "euphoria",
+       "f1",
+       "falcon",
+       "fo",
+       "fortran",
+       "freebasic",
+       "freeswitch",
+       "fsharp",
+       "gambas",
+       "gdb",
+       "genero",
+       "genie",
+       "gettext",
+       "glsl",
+       "gml",
+       "gnuplot",
+       "go",
+       "groovy",
+       "gwbasic",
+       "haskell",
+       "haxe",
+       "hicest",
+       "hq9plus",
+       "html4strict",
+       "html5",
+       "icon",
+       "idl",
+       "ini",
+       "inno",
+       "intercal",
+       "io",
+       "j",
+       "java",
+       "java5",
+       "javascript",
+       "jquery",
+       "kixtart",
+       "klonec",
+       "klonecpp",
+       "latex",
+       "lb",
+       "ldif",
+       "lisp",
+       "llvm",
+       "locobasic",
+       "logtalk",
+       "lolcode",
+       "lotusformulas",
+       "lotusscript",
+       "lscript",
+       "lsl2",
+       "lua",
+       "m68k",
+       "magiksf",
+       "make",
+       "mapbasic",
+       "matlab",
+       "mirc",
+       "mmix",
+       "modula2",
+       "modula3",
+       "mpasm",
+       "mxml",
+       "mysql",
+       "nagios",
+       "netrexx",
+       "newlisp",
+       "nsis",
+       "oberon2",
+       "objc",
+       "objeck",
+       "ocaml",
+       "octave",
+       "oobas",
+       "oorexx",
+       "oracle11",
+       "oracle8",
+       "oxygene",
+       "oz",
+       "parasail",
+       "parigp",
+       "pascal",
+       "pcre",
+       "per",
+       "perl",
+       "perl6",
+       "pf",
+       "php",
+       "pic16",
+       "pike",
+       "pixelbender",
+       "pli",
+       "plsql",
+       "postgresql",
+       "povray",
+       "powerbuilder",
+       "powershell",
+       "proftpd",
+       "progress",
+       "prolog",
+       "properties",
+       "providex",
+       "purebasic",
+       "pycon",
+       "pys60",
+       "python",
+       "q",
+       "qbasic",
+       "rails",
+       "rebol",
+       "reg",
+       "rexx",
+       "robots",
+       "rpmspec",
+       "rsplus",
+       "ruby",
+       "sas",
+       "scala",
+       "scheme",
+       "scilab",
+       "sdlbasic",
+       "smalltalk",
+       "smarty",
+       "spark",
+       "sparql",
+       "sql",
+       "stonescript",
+       "systemverilog",
+       "tcl",
+       "teraterm",
+       "text",
+       "thinbasic",
+       "tsql",
+       "typoscript",
+       "unicon",
+       "upc",
+       "urbi",
+       "uscript",
+       "vala",
+       "vb",
+       "vbnet",
+       "vedit",
+       "verilog",
+       "vhdl",
+       "vim",
+       "visualfoxpro",
+       "visualprolog",
+       "whitespace",
+       "whois",
+       "winbatch",
+       "xbasic",
+       "xml",
+       "xpp",
+       "yaml",
+       "z80",
+       "zxbasic"
+);
diff --git a/SyntaxHighlight_GeSHi.php b/SyntaxHighlight_GeSHi.php
index caf3b30..bb3ca39 100644
--- a/SyntaxHighlight_GeSHi.php
+++ b/SyntaxHighlight_GeSHi.php
@@ -36,6 +36,8 @@
        die();
 }
 
+include_once __DIR__ . '/SyntaxHighlight_GeSHi.langs.php';
+
 $wgExtensionCredits['parserhook']['SyntaxHighlight_GeSHi'] = array(
        'path'           => __FILE__,
        'name'           => 'SyntaxHighlight',
diff --git a/maintenance/updateLanguageList.php 
b/maintenance/updateLanguageList.php
new file mode 100644
index 0000000..2adae8c
--- /dev/null
+++ b/maintenance/updateLanguageList.php
@@ -0,0 +1,51 @@
+<?php
+/**
+ * Script to update list of supported languages.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @author Ori Livneh <[email protected]>
+ * @ingroup Maintenance
+ */
+
+$IP = getenv( 'MW_INSTALL_PATH' ) ?: __DIR__ . '/../../..';
+
+require_once "$IP/maintenance/Maintenance.php";
+require_once __DIR__ . "/../geshi/geshi.php";
+
+class UpdateLanguageList extends Maintenance {
+       public function __construct() {
+               parent::__construct();
+               $this->addDescription( 'Update list of languages supported by 
SyntaxHighlight_GeSHi' );
+       }
+
+       public function execute() {
+               global $IP;
+
+               $geshi = new GeSHi;
+               $header = '// Generated by ' . basename( __FILE__ ) . ' on ' . 
date( DATE_RFC2822 ) . "\n";
+               $langs = array_values( array_filter( 
$geshi->get_supported_languages( false ), 'ctype_alnum' ) );
+               sort( $langs );
+               $replace = array( '[' => "array(\n\t", ']' => "\n);\n", '",' => 
"\",\n\t" );
+               $code = "<?php\n" . $header . '$wgGeSHiSupportedLanguages = ' . 
strtr( json_encode( $langs ), $replace );
+               file_put_contents( __DIR__ . 
'/../SyntaxHighlight_GeSHi.langs.php', $code );
+               $this->output( "Updated language list written to 
SyntaxHighlight_GeSHi.langs.php\n" );
+       }
+}
+
+$maintClass = "UpdateLanguageList";
+require_once( RUN_MAINTENANCE_IF_MAIN );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie0be7c42fa6716555c3e03e3f28734d7e0302664
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SyntaxHighlight_GeSHi
Gerrit-Branch: wmf/1.25wmf7
Gerrit-Owner: Ori.livneh <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to