From 0998c41943459bec74b95397976f6fed25b99c4a Mon Sep 17 00:00:00 2001 From: MaxSem Date: Sun, 12 Jan 2014 23:59:44 +0000 Subject: [PATCH] Revert "Include short descriptions for extensions bundled in the release" Contains var_dump(), self-merged non-trivial code. This reverts commit 96b2c66e242954d8591e7b8ca7b9d6a2a4e1074a. Change-Id: Ie630466ef50e6bcdabf01daff28c283c764aae35 --- includes/cache/LinkCache.php | 18 --- includes/cache/LocalisationCache.php | 19 --- includes/installer/Installer.php | 38 +---- includes/installer/LocalSettingsGenerator.php | 13 +- includes/installer/WebInstaller.php | 4 +- includes/installer/WebInstallerPage.php | 27 +--- includes/parser/LinkHolderArray.php | 138 +++++++++--------- skins/common/config.css | 8 +- 8 files changed, 84 insertions(+), 181 deletions(-) diff --git a/includes/cache/LinkCache.php b/includes/cache/LinkCache.php index 169816b8f3..de2a728b06 100644 --- a/includes/cache/LinkCache.php +++ b/includes/cache/LinkCache.php @@ -35,7 +35,6 @@ class LinkCache { private $mGoodLinkFields = array(); private $mBadLinks = array(); private $mForUpdate = false; - private $useDatabase = true; /** * @var LinkCache @@ -210,19 +209,6 @@ class LinkCache { } } - /** - * Enable or disable database use. - * @since 1.22 - * @param $value Boolean - * @return Boolean - */ - public function useDatabase( $value = null ) { - if ( $value !== null ) { - $this->useDatabase = (bool)$value; - } - return $this->useDatabase; - } - /** * Add a title to the link cache, return the page_id or zero if non-existent * @@ -253,10 +239,6 @@ class LinkCache { return 0; } - if( !$this->useDatabase ) { - return 0; - } - # Some fields heavily used for linking... if ( $this->mForUpdate ) { $db = wfGetDB( DB_MASTER ); diff --git a/includes/cache/LocalisationCache.php b/includes/cache/LocalisationCache.php index 321d476ca4..cba2ba7932 100644 --- a/includes/cache/LocalisationCache.php +++ b/includes/cache/LocalisationCache.php @@ -1027,25 +1027,6 @@ class LocalisationCache { $this->store = new LCStoreNull; $this->manualRecache = false; } - - /** - * Return an array with initialised languages. - * - * @return array - */ - public function getInitialisedLanguages() { - return $this->initialisedLangs; - } - - /** - * Set initialised languages. - * - * @param array $languages Optional array of initialised languages. - */ - public function setInitialisedLanguages( $languages = array() ) { - $this->initialisedLangs = $languages; - } - } /** diff --git a/includes/installer/Installer.php b/includes/installer/Installer.php index e7ef537620..765838bd1f 100644 --- a/includes/installer/Installer.php +++ b/includes/installer/Installer.php @@ -1407,24 +1407,6 @@ abstract class Installer { return "{$_SERVER['PHP_SELF']}?page=" . urlencode( $page ); } - /** - * Load the extension credits for i18n strings. Very hacky for - * now, but I expect it only be used for 1.22.0 at the most. - */ - public function getExtensionInfo( $file ) { - global $wgExtensionCredits, $wgVersion, $wgResourceModules; - - $wgVersion = "1.22"; - $wgResourceModules = array(); - require_once $file ; - $e = array_values( $wgExtensionCredits ); - if( $e ) { - $ext = array_values( $e[0] ); - $wgExtensionCredits = array(); - return $ext[0]; - } - } - /** * Finds extensions that follow the format /extensions/Name/Name.php, * and returns an array containing the value for 'Name' for each found extension. @@ -1447,22 +1429,13 @@ abstract class Installer { if ( !is_dir( "$extDir/$file" ) ) { continue; } - - $extFile = "$extDir/$file/$file.php"; - $extI18NFile = "$extDir/$file/$file.i18n.php"; - if ( file_exists( $extFile ) ) { - if ( $info = $this->getExtensionInfo( $extFile ) ) { - $exts[$info['name']] = $info; - - if ( file_exists( $extI18NFile ) ) { - global $wgExtensionMessagesFiles; - $wgExtensionMessagesFiles[$file] = $extI18NFile; - } - } + if ( file_exists( "$extDir/$file/$file.php" ) ) { + $exts[] = $file; } } closedir( $dh ); - uksort( $exts, 'strnatcasecmp' ); + natcasesort( $exts ); + return $exts; } @@ -1489,9 +1462,8 @@ abstract class Installer { require "$IP/includes/DefaultSettings.php"; - $extensions = $this->findExtensions(); foreach ( $exts as $e ) { - require_once $extensions[$e]['path']; + require_once "$IP/extensions/$e/$e.php"; } $hooksWeWant = isset( $wgHooks['LoadExtensionSchemaUpdates'] ) ? diff --git a/includes/installer/LocalSettingsGenerator.php b/includes/installer/LocalSettingsGenerator.php index 6b72047b24..68664c955c 100644 --- a/includes/installer/LocalSettingsGenerator.php +++ b/includes/installer/LocalSettingsGenerator.php @@ -137,21 +137,14 @@ class LocalSettingsGenerator { $localSettings = $this->getDefaultText(); if ( count( $this->extensions ) ) { - $extensions = $this->installer->findExtensions(); $localSettings .= " # Enabled Extensions. Most extensions are enabled by including the base extension file here # but check specific extension documentation for more details # The following extensions were automatically enabled:\n"; - $ip = $this->installer->getVar( 'IP' ); - foreach ( $this->extensions as $ext) { - $path = str_replace( $ip, '', $extensions[$ext]['path'] ); - $prefix = ''; - if ( $path !== $extensions[$ext]['path'] ) { - $prefix = '$IP'; - } - $path = $prefix . self::escapePhpString( $path ); - $localSettings .= "require_once \"$path\";\n"; + foreach ( $this->extensions as $extName ) { + $encExtName = self::escapePhpString( $extName ); + $localSettings .= "require_once \"\$IP/extensions/$encExtName/$encExtName.php\";\n"; } } diff --git a/includes/installer/WebInstaller.php b/includes/installer/WebInstaller.php index 25470207e0..79fdc99319 100644 --- a/includes/installer/WebInstaller.php +++ b/includes/installer/WebInstaller.php @@ -923,10 +923,8 @@ class WebInstaller extends Installer { } if ( isset( $params['rawtext'] ) ) { $labelText = $params['rawtext']; - } elseif ( isset( $params['label'] ) ) { - $labelText = $this->parse( wfMessage( $params['label'] )->text() ); } else { - $labelText = ""; + $labelText = $this->parse( wfMessage( $params['label'] )->text() ); } return "
\n" . diff --git a/includes/installer/WebInstallerPage.php b/includes/installer/WebInstallerPage.php index b12b686b10..d4b3d65713 100644 --- a/includes/installer/WebInstallerPage.php +++ b/includes/installer/WebInstallerPage.php @@ -948,20 +948,11 @@ class WebInstaller_Options extends WebInstallerPage { if ( $extensions ) { $extHtml = $this->getFieldSetStart( 'config-extensions' ); - /* Force a recache, so we load extensions descriptions */ - global $wgLang; - $lc = Language::getLocalisationCache(); - $lc->setInitialisedLanguages( array() ); - $lc->getItem( $wgLang->mCode, '' ); - LinkCache::singleton()->useDatabase( false ); - foreach ( $extensions as $ext ) { $extHtml .= $this->parent->getCheckBox( array( - 'var' => "ext-{$ext['name']}", - 'rawtext' => "{$ext['name']}: " . - wfMessage( $ext['descriptionmsg'] )->useDatabase( false )->parse(), - ) ); - + 'var' => "ext-$ext", + 'rawtext' => $ext, + ) ); } $extHtml .= $this->parent->getHelpBox( 'config-extensions-help' ) . @@ -1184,17 +1175,11 @@ class WebInstaller_Options extends WebInstallerPage { $this->setVar( 'wgRightsIcon', '' ); } - $extsAvailable = array_map( - function($e) { - if( isset($e['name']) ) { - return $e['name']; - } - }, $this->parent->findExtensions() ); + $extsAvailable = $this->parent->findExtensions(); $extsToInstall = array(); - foreach ( $extsAvailable as $key => $ext ) { - var_dump("config_ext-$ext"); + foreach ( $extsAvailable as $ext ) { if ( $this->parent->request->getCheck( 'config_ext-' . $ext ) ) { - $extsToInstall[] = $extsAvailable[ $key ]; + $extsToInstall[] = $ext; } } $this->parent->setVar( '_Extensions', $extsToInstall ); diff --git a/includes/parser/LinkHolderArray.php b/includes/parser/LinkHolderArray.php index 46a0760845..40c0a89b82 100644 --- a/includes/parser/LinkHolderArray.php +++ b/includes/parser/LinkHolderArray.php @@ -280,87 +280,85 @@ class LinkHolderArray { $linkCache = LinkCache::singleton(); $output = $this->parent->getOutput(); - if( $linkCache->useDatabase() ) { - wfProfileIn( __METHOD__ . '-check' ); - $dbr = wfGetDB( DB_SLAVE ); - $threshold = $this->parent->getOptions()->getStubThreshold(); - - # Sort by namespace - ksort( $this->internals ); + wfProfileIn( __METHOD__ . '-check' ); + $dbr = wfGetDB( DB_SLAVE ); + $threshold = $this->parent->getOptions()->getStubThreshold(); - $linkcolour_ids = array(); + # Sort by namespace + ksort( $this->internals ); - # Generate query - $queries = array(); - foreach ( $this->internals as $ns => $entries ) { - foreach ( $entries as $entry ) { - $title = $entry['title']; - $pdbk = $entry['pdbk']; + $linkcolour_ids = array(); - # Skip invalid entries. - # Result will be ugly, but prevents crash. - if ( is_null( $title ) ) { - continue; - } + # Generate query + $queries = array(); + foreach ( $this->internals as $ns => $entries ) { + foreach ( $entries as $entry ) { + $title = $entry['title']; + $pdbk = $entry['pdbk']; - # Check if it's a static known link, e.g. interwiki - if ( $title->isAlwaysKnown() ) { - $colours[$pdbk] = ''; - } elseif ( $ns == NS_SPECIAL ) { - $colours[$pdbk] = 'new'; - } elseif ( ( $id = $linkCache->getGoodLinkID( $pdbk ) ) != 0 ) { - $colours[$pdbk] = Linker::getLinkColour( $title, $threshold ); - $output->addLink( $title, $id ); - $linkcolour_ids[$id] = $pdbk; - } elseif ( $linkCache->isBadLink( $pdbk ) ) { - $colours[$pdbk] = 'new'; - } else { - # Not in the link cache, add it to the query - $queries[$ns][] = $title->getDBkey(); - } - } - } - if ( $queries ) { - $where = array(); - foreach ( $queries as $ns => $pages ) { - $where[] = $dbr->makeList( - array( - 'page_namespace' => $ns, - 'page_title' => $pages, - ), - LIST_AND - ); + # Skip invalid entries. + # Result will be ugly, but prevents crash. + if ( is_null( $title ) ) { + continue; } - $res = $dbr->select( - 'page', - array( 'page_id', 'page_namespace', 'page_title', 'page_is_redirect', 'page_len', 'page_latest' ), - $dbr->makeList( $where, LIST_OR ), - __METHOD__ - ); - - # Fetch data and form into an associative array - # non-existent = broken - foreach ( $res as $s ) { - $title = Title::makeTitle( $s->page_namespace, $s->page_title ); - $pdbk = $title->getPrefixedDBkey(); - $linkCache->addGoodLinkObjFromRow( $title, $s ); - $output->addLink( $title, $s->page_id ); - # @todo FIXME: Convoluted data flow - # The redirect status and length is passed to getLinkColour via the LinkCache - # Use formal parameters instead + # Check if it's a static known link, e.g. interwiki + if ( $title->isAlwaysKnown() ) { + $colours[$pdbk] = ''; + } elseif ( $ns == NS_SPECIAL ) { + $colours[$pdbk] = 'new'; + } elseif ( ( $id = $linkCache->getGoodLinkID( $pdbk ) ) != 0 ) { $colours[$pdbk] = Linker::getLinkColour( $title, $threshold ); - //add id to the extension todolist - $linkcolour_ids[$s->page_id] = $pdbk; + $output->addLink( $title, $id ); + $linkcolour_ids[$id] = $pdbk; + } elseif ( $linkCache->isBadLink( $pdbk ) ) { + $colours[$pdbk] = 'new'; + } else { + # Not in the link cache, add it to the query + $queries[$ns][] = $title->getDBkey(); } - unset( $res ); } - if ( count( $linkcolour_ids ) ) { - //pass an array of page_ids to an extension - wfRunHooks( 'GetLinkColours', array( $linkcolour_ids, &$colours ) ); + } + if ( $queries ) { + $where = array(); + foreach ( $queries as $ns => $pages ) { + $where[] = $dbr->makeList( + array( + 'page_namespace' => $ns, + 'page_title' => $pages, + ), + LIST_AND + ); } - wfProfileOut( __METHOD__ . '-check' ); + + $res = $dbr->select( + 'page', + array( 'page_id', 'page_namespace', 'page_title', 'page_is_redirect', 'page_len', 'page_latest' ), + $dbr->makeList( $where, LIST_OR ), + __METHOD__ + ); + + # Fetch data and form into an associative array + # non-existent = broken + foreach ( $res as $s ) { + $title = Title::makeTitle( $s->page_namespace, $s->page_title ); + $pdbk = $title->getPrefixedDBkey(); + $linkCache->addGoodLinkObjFromRow( $title, $s ); + $output->addLink( $title, $s->page_id ); + # @todo FIXME: Convoluted data flow + # The redirect status and length is passed to getLinkColour via the LinkCache + # Use formal parameters instead + $colours[$pdbk] = Linker::getLinkColour( $title, $threshold ); + //add id to the extension todolist + $linkcolour_ids[$s->page_id] = $pdbk; + } + unset( $res ); + } + if ( count( $linkcolour_ids ) ) { + //pass an array of page_ids to an extension + wfRunHooks( 'GetLinkColours', array( $linkcolour_ids, &$colours ) ); } + wfProfileOut( __METHOD__ . '-check' ); # Do a second query for different language variants of links and categories if ( $wgContLang->hasVariants() ) { diff --git a/skins/common/config.css b/skins/common/config.css index 79780da9e6..39206c3a00 100644 --- a/skins/common/config.css +++ b/skins/common/config.css @@ -88,13 +88,7 @@ } .config-input-check { - margin-left: 3.7em; - margin-right: 2em; - margin-bottom: 0.25em; -} - -.config-input-check input { - margin-left: -1em; + margin-left: 10em; } .error { -- 2.20.1