public function execute() { $this->dataDir = $this->getOption('data-dir', '.'); $allkeysPresent = file_exists("{$this->dataDir}/allkeys.txt"); $ucdallPresent = file_exists("{$this->dataDir}/ucd.all.grouped.xml"); // As of January 2013, these links work for all versions of Unicode // between 5.1 and 6.2, inclusive. $allkeysURL = "http://www.unicode.org/Public/UCA/<Unicode version>/allkeys.txt"; $ucdallURL = "http://www.unicode.org/Public/<Unicode version>/ucdxml/ucd.all.grouped.zip"; if (!$allkeysPresent || !$ucdallPresent) { $icuVersion = IcuCollation::getICUVersion(); $unicodeVersion = IcuCollation::getUnicodeVersionForICU(); $error = ""; if (!$allkeysPresent) { $error .= "Unable to find allkeys.txt. " . "Download it and specify its location with --data-dir=<DIR>. " . "\n\n"; } if (!$ucdallPresent) { $error .= "Unable to find ucd.all.grouped.xml. " . "Download it, unzip, and specify its location with --data-dir=<DIR>. " . "\n\n"; } $versionKnown = false; if (!$icuVersion) { // Unknown version - either very old intl, // or PHP < 5.3.7 which does not expose this information $error .= "As MediaWiki could not determine the version of ICU library used by your PHP's " . "intl extension it can't suggest which file version to download. " . "This can be caused by running a very old version of intl or PHP < 5.3.7. " . "If you are sure everything is all right, find out the ICU version " . "by running phpinfo(), check what is the Unicode version it is using " . "at http://site.icu-project.org/download, then try finding appropriate data file(s) at:"; } elseif (version_compare($icuVersion, "4.0", "<")) { // Extra old version $error .= "You are using outdated version of ICU ({$icuVersion}), intended for " . ($unicodeVersion ? "Unicode {$unicodeVersion}" : "an unknown version of Unicode") . "; this file might not be avalaible for it, and it's not supported by MediaWiki. " . " You are on your own; consider upgrading PHP's intl extension or try " . "one of the files available at:"; } elseif (version_compare($icuVersion, "51.0", ">=")) { // Extra recent version $error .= "You are using ICU {$icuVersion}, released after this script was last updated. " . "Check what is the Unicode version it is using at http://site.icu-project.org/download . " . "It can't be guaranteed everything will work, but appropriate file(s) should " . "be available at:"; } else { // ICU 4.0 to 50.x $versionKnown = true; $error .= "You are using ICU {$icuVersion}, intended for " . ($unicodeVersion ? "Unicode {$unicodeVersion}" : "an unknown version of Unicode") . ". Appropriate file(s) should be available at:"; } $error .= "\n"; if ($versionKnown && $unicodeVersion) { $allkeysURL = str_replace("<Unicode version>", "{$unicodeVersion}.0", $allkeysURL); $ucdallURL = str_replace("<Unicode version>", "{$unicodeVersion}.0", $ucdallURL); } if (!$allkeysPresent) { $error .= "* {$allkeysURL}\n"; } if (!$ucdallPresent) { $error .= "* {$ucdallURL}\n"; } $this->error($error); exit(1); } $debugOutFileName = $this->getOption('debug-output'); if ($debugOutFileName) { $this->debugOutFile = fopen($debugOutFileName, 'w'); if (!$this->debugOutFile) { $this->error("Unable to open debug output file for writing"); exit(1); } } $this->loadUcd(); $this->generateFirstChars(); }
/** * Return the version of Unicode appropriate for the version of ICU library * currently in use, or false when it can't be determined. * * @since 1.21 * @return string|bool */ static function getUnicodeVersionForICU() { $icuVersion = IcuCollation::getICUVersion(); if (!$icuVersion) { return false; } $versionPrefix = substr($icuVersion, 0, 3); // Source: http://site.icu-project.org/download $map = array('50.' => '6.2', '49.' => '6.1', '4.8' => '6.0', '4.6' => '6.0', '4.4' => '5.2', '4.2' => '5.1', '4.0' => '5.1', '3.8' => '5.0', '3.6' => '5.0', '3.4' => '4.1'); if (isset($map[$versionPrefix])) { return $map[$versionPrefix]; } else { return false; } }
/** * Returns wiki text showing the third party software versions (apache, php, mysql). * * @return string */ public static function softwareInformation() { $dbr = wfGetDB(DB_REPLICA); // Put the software in an array of form 'name' => 'version'. All messages should // be loaded here, so feel free to use wfMessage in the 'name'. Raw HTML or // wikimarkup can be used. $software = []; $software['[https://www.mediawiki.org/ MediaWiki]'] = self::getVersionLinked(); if (wfIsHHVM()) { $software['[http://hhvm.com/ HHVM]'] = HHVM_VERSION . " (" . PHP_SAPI . ")"; } else { $software['[https://php.net/ PHP]'] = PHP_VERSION . " (" . PHP_SAPI . ")"; } $software[$dbr->getSoftwareLink()] = $dbr->getServerInfo(); if (IcuCollation::getICUVersion()) { $software['[http://site.icu-project.org/ ICU]'] = IcuCollation::getICUVersion(); } // Allow a hook to add/remove items. Hooks::run('SoftwareInfo', [&$software]); $out = Xml::element('h2', ['id' => 'mw-version-software'], wfMessage('version-software')->text()) . Xml::openElement('table', ['class' => 'wikitable plainlinks', 'id' => 'sv-software']) . "<tr>\n\t\t\t\t\t<th>" . wfMessage('version-software-product')->text() . "</th>\n\t\t\t\t\t<th>" . wfMessage('version-software-version')->text() . "</th>\n\t\t\t\t</tr>\n"; foreach ($software as $name => $version) { $out .= "<tr>\n\t\t\t\t\t<td>" . $name . "</td>\n\t\t\t\t\t<td dir=\"ltr\">" . $version . "</td>\n\t\t\t\t</tr>\n"; } return $out . Xml::closeElement('table'); }