Merge branch 'master' of ssh://gerrit.wikimedia.org:29418/mediawiki/core into Wikidata
authordaniel <daniel.kinzler@wikimedia.de>
Mon, 11 Jun 2012 15:45:59 +0000 (17:45 +0200)
committerdaniel <daniel.kinzler@wikimedia.de>
Mon, 11 Jun 2012 15:45:59 +0000 (17:45 +0200)
1  2 
includes/DefaultSettings.php
includes/parser/Parser.php
languages/messages/MessagesQqq.php
maintenance/refreshLinks.php
tests/phpunit/maintenance/backupPrefetchTest.php
tests/phpunit/maintenance/backupTextPassTest.php

@@@ -660,40 -660,6 +660,40 @@@ $wgMediaHandlers = array
        'image/x-djvu' => 'DjVuHandler', // compat
  );
  
 +/**
 + * Plugins for page content model handling.
 + * Each entry in the array maps a model id to a class name
 + */
 +$wgContentHandlers = array(
 +    CONTENT_MODEL_WIKITEXT => 'WikitextContentHandler', // the usual case
 +    CONTENT_MODEL_JAVASCRIPT => 'JavaScriptContentHandler', // dumb version, no syntax highlighting
 +    CONTENT_MODEL_CSS => 'CssContentHandler', // dumb version, no syntax highlighting
 +    CONTENT_MODEL_TEXT => 'TextContentHandler', // dumb plain text in <pre>
 +);
 +
 +/**
 + * Mime types for content formats.
 + * Each entry in the array maps a content format to a mime type.
 + *
 + * Extensions that define their own content formats can register
 + * the appropriate mime types in this array.
 + *
 + * Such extensions shall use content format IDs
 + * larger than 100 and register the ids they use at
 + * <http://mediawiki.org/ContentHandler/registry>
 + * to avoid conflicts with other extensions.
 + */
 +$wgContentFormatMimeTypes = array(
 +      CONTENT_FORMAT_WIKITEXT => 'text/x-wiki',
 +      CONTENT_FORMAT_JAVASCRIPT => 'text/javascript',
 +      CONTENT_FORMAT_CSS => 'text/css',
 +      CONTENT_FORMAT_TEXT => 'text/plain',
 +      CONTENT_FORMAT_HTML => 'text/html',
 +      CONTENT_FORMAT_XML => 'application/xml',
 +      CONTENT_FORMAT_JSON => 'application/json',
 +      CONTENT_FORMAT_SERIALIZED => 'application/vnd.php.serialized',
 +);
 +
  /**
   * Resizing can be done using PHP's internal image libraries or using
   * ImageMagick or another third-party converter, e.g. GraphicMagick.
@@@ -3493,12 -3459,19 +3493,19 @@@ $wgSysopEmailBans = true
   * Limits on the possible sizes of range blocks.
   *
   * CIDR notation is hard to understand, it's easy to mistakenly assume that a
-  * /1 is a small range and a /31 is a large range. Setting this to half the
-  * number of bits avoids such errors for IPv4.
+  * /1 is a small range and a /31 is a large range. For IPv4, setting a limit of
+  * half the number of bits avoids such errors, and allows entire ISPs to be
+  * blocked using a small number of range blocks.
+  *
+  * For IPv6, RFC 3177 recommends that a /48 be allocated to every residential
+  * customer, so range blocks larger than /64 (half the number of bits) will
+  * plainly be required. RFC 4692 implies that a very large ISP may be
+  * allocated a /19 if a generous HD-Ratio of 0.8 is used, so we will use that
+  * as our limit. As of 2012, blocking the whole world would require a /4 range.
   */
  $wgBlockCIDRLimit = array(
        'IPv4' => 16, # Blocks larger than a /16 (64k addresses) will not be allowed
-       'IPv6' => 32, # Blocks larger than a /32 (~7.9x10^28 addresses) will not be allowed
+       'IPv6' => 19,
  );
  
  /**
@@@ -5887,31 -5860,6 +5894,31 @@@ $wgSeleniumConfigFile = null
  $wgDBtestuser = ''; //db user that has permission to create and drop the test databases only
  $wgDBtestpassword = '';
  
 +/**
 + * Associative array mapping namespace IDs to the name of the content model pages in that namespace should have by
 + * default (use the CONTENT_MODEL_XXX constants). If no special content type is defined for a given namespace,
 + * pages in that namespace will  use the CONTENT_MODEL_WIKITEXT (except for the special case of JS and CS pages).
 + */
 +$wgNamespaceContentModels = array();
 +
 +/**
 + * How to react if a plain text version of a non-text Content object is requested using ContentHandler::getContentText():
 + *
 + * * 'ignore': return null
 + * * 'fail': throw an MWException
 + * * 'serializeContent': serializeContent to default format
 + */
 +$wgContentHandlerTextFallback = 'ignore';
 +
 +/**
 + * Compatibility switch for running ContentHandler code withoput a schema update.
 + * Set to false to disable use of the database fields introduced by the ContentHandler facility.
 + *
 + * @deprecated this is only here to allow code deployment without a database schema update on large sites.
 + *             get rid of it in the next version.
 + */
 +$wgContentHandlerUseDB = true;
 +
  /**
   * For really cool vim folding this needs to be at the end:
   * vim: foldmarker=@{,@} foldmethod=marker
@@@ -2859,7 -2859,8 +2859,8 @@@ class Parser 
                                $value = $pageLang->formatNum( SiteStats::edits() );
                                break;
                        case 'numberofviews':
-                               $value = $pageLang->formatNum( SiteStats::views() );
+                               global $wgDisableCounters;
+                               $value = !$wgDisableCounters ? $pageLang->formatNum( SiteStats::views() ) : '';
                                break;
                        case 'currenttimestamp':
                                $value = wfTimestamp( TS_MW, $ts );
                        }
  
                        if ( $rev ) {
 -                              $text = $rev->getText();
 +                              $content = $rev->getContent();
 +                              $text = $content->getWikitextForTransclusion();
 +
 +                              if ( $text === false || $text === null ) {
 +                                      $text = false;
 +                                      break;
 +                              }
                        } elseif ( $title->getNamespace() == NS_MEDIAWIKI ) {
                                global $wgContLang;
                                $message = wfMessage( $wgContLang->lcfirst( $title->getText() ) )->inContentLanguage();
                                        break;
                                }
                                $text = $message->plain();
 +                              $content = ContentHandler::makeContent( $text, $title ); #TODO: use Message::content() instead, once that exists
                        } else {
                                break;
                        }
 -                      if ( $text === false ) {
 +                      if ( !$content ) {
                                break;
                        }
                        # Redirect?
                        $finalTitle = $title;
 -                      $title = Title::newFromRedirect( $text );
 +                      $title = $content->getRedirectTarget();
                }
                return array(
                        'text' => $text,
@@@ -414,7 -414,7 +414,7 @@@ Also used as title of [[Special:Search]
  'edit' => 'The text of the tab going to the edit form. When the page is protected, you will see "[[MediaWiki:Viewsource/{{SUBPAGENAME}}|{{int:viewsource}}]]". Should be in the infinitive mood.
  
  {{Identical|Edit}}',
- 'create' => 'The text on the tab for to the edit form on unexisting pages.
+ 'create' => 'The text on the tab of the edit form on unexisting pages starts editing them.
  
  {{Identical|Create}}',
  'editthispage' => 'This is the "edit" link as used in the skins Classic/Standard, Cologne Blue and Nostalgia. See {{msg|create-this-page}} for when the page does not exist.',
@@@ -1980,7 -1980,9 +1980,9 @@@ Extensions making use of it
  'backend-fail-batchsize' => 'Error message when the limit of operations to be done at once in the file backend was reached.
  Parameters:
  * $1 is the number of operations attempted at once in this case.
- * $2 is the maximum number of operations that can be attempted at once.',
+ * $2 is the maximum number of operations that can be attempted at once.
+ A "[[:wikipedia:Front and back ends|backend]]" is a system or component that ordinary users don\'t interact with directly and don\'t need to know about, and that is responsible for a distinct task or service - for example, a storage back-end is a generic system for storing data which other applications can use. Possible alternatives for back-end are "system" or "service", or (depending on context and language) even leave it untranslated.',
  'backend-fail-usable' => 'Parameters:
  * $1 is the file name, including the path, formatted for the storage backend used',
  
@@@ -4736,10 -4738,4 +4738,10 @@@ $4 is the gender of the target user.'
  'api-error-uploaddisabled' => 'API error message that can be used for client side localisation of API errors.',
  'api-error-verification-error' => 'The word "extension" refers to the part behind the last dot in a file name, that by convention gives a hint about the kind of data format which a files contents are in.',
  
 +# Content model IDs for the ContentHandler facility; used by ContentHander::getContentModel()
 +'content-model-1' => 'Name for the wikitext content model, used when decribing what type of content a page contains.',
 +'content-model-2' => 'Name for the JavaScript content model, used when decribing what type of content a page contains.',
 +'content-model-3' => 'Name for the CSS content model, used when decribing what type of content a page contains.',
 +'content-model-4' => 'Name for the plain text content model, used when decribing what type of content a page contains.',
 +
  );
@@@ -210,17 -210,18 +210,17 @@@ class RefreshLinks extends Maintenance 
                        return;
                }
  
 -              $text = $page->getRawText();
 -              if ( $text === false ) {
 +              $content = $page->getContent( REVISION::RAW );
 +              if ( null === false ) {
                        return;
                }
  
                $dbw = wfGetDB( DB_MASTER );
                $dbw->begin( __METHOD__ );
  
 -              $options = ParserOptions::newFromUserAndLang( new User, $wgContLang );
 -              $parserOutput = $wgParser->parse( $text, $page->getTitle(), $options, true, true, $page->getLatest() );
 -              $update = new LinksUpdate( $page->getTitle(), $parserOutput, false );
 -              $update->doUpdate();
 +              $contentHandler = $content->getContentHandler();
 +              $updates = $contentHandler->getSecondaryDataUpdates( $content, $page->getTitle() );
 +              DataUpdate::runUpdates( $updates );
  
                $dbw->commit( __METHOD__ );
        }
                                $dbw->delete( $table, array( $field => $list ), __METHOD__ );
                        }
                        $this->output( "\n" );
+                       wfWaitForSlaves();
                }
                $lb->closeAll();
        }
@@@ -1,6 -1,6 +1,6 @@@
  <?php
- global $IP;
- require_once( "$IP/maintenance/backupPrefetch.inc" );
+ require_once dirname( __FILE__ ) . "/../../../maintenance/backupPrefetch.inc";
  
  /**
   * Tests for BaseDump
@@@ -197,8 -197,6 +197,8 @@@ class BaseDumpTest extends MediaWikiTes
        <comment>BackupDumperTestP1Summary1</comment>
        <text xml:space="preserve">BackupDumperTestP1Text1</text>
        <sha1>0bolhl6ol7i6x0e7yq91gxgaan39j87</sha1>
 +      <model name="wikitext">1</model>
 +      <format mime="text/x-wiki">1</format>
      </revision>
    </page>
  ';
        <comment>BackupDumperTestP2Summary1</comment>
        <text xml:space="preserve">BackupDumperTestP2Text1</text>
        <sha1>jprywrymfhysqllua29tj3sc7z39dl2</sha1>
 +      <model name="wikitext">1</model>
 +      <format mime="text/x-wiki">1</format>
      </revision>
      <revision>
        <id>5</id>
        <comment>BackupDumperTestP2Summary4 extra</comment>
        <text xml:space="preserve">BackupDumperTestP2Text4 some additional Text</text>
        <sha1>6o1ciaxa6pybnqprmungwofc4lv00wv</sha1>
 +      <model name="wikitext">1</model>
 +      <format mime="text/x-wiki">1</format>
      </revision>
    </page>
  ';
        <comment>Talk BackupDumperTestP1 Summary1</comment>
        <text xml:space="preserve">Talk about BackupDumperTestP1 Text1</text>
        <sha1>nktofwzd0tl192k3zfepmlzxoax1lpe</sha1>
 +      <model name="wikitext">1</model>
 +      <format mime="text/x-wiki">1</format>
      </revision>
    </page>
  ';
@@@ -1,7 -1,6 +1,6 @@@
  <?php
- global $IP;
- require_once( "$IP/maintenance/backup.inc" );
- require_once( "$IP/maintenance/backupTextPass.inc" );
+ require_once dirname( __FILE__ ) . "/../../../maintenance/backupTextPass.inc";
  
  /**
   * Tests for page dumps of BackupDumper
@@@ -479,8 -478,6 +478,8 @@@ class TextPassDumperTest extends DumpTe
        </contributor>
        <comment>BackupDumperTestP1Summary1</comment>
        <sha1>0bolhl6ol7i6x0e7yq91gxgaan39j87</sha1>
 +      <model name="wikitext">1</model>
 +      <format mime="text/x-wiki">1</format>
        <text id="' . $this->textId1_1 . '" bytes="23" />
      </revision>
    </page>
        </contributor>
        <comment>BackupDumperTestP2Summary1</comment>
        <sha1>jprywrymfhysqllua29tj3sc7z39dl2</sha1>
 +      <model name="wikitext">1</model>
 +      <format mime="text/x-wiki">1</format>
        <text id="' . $this->textId2_1 . '" bytes="23" />
      </revision>
      <revision>
        </contributor>
        <comment>BackupDumperTestP2Summary2</comment>
        <sha1>b7vj5ks32po5m1z1t1br4o7scdwwy95</sha1>
 +      <model name="wikitext">1</model>
 +      <format mime="text/x-wiki">1</format>
        <text id="' . $this->textId2_2 . '" bytes="23" />
      </revision>
      <revision>
        </contributor>
        <comment>BackupDumperTestP2Summary3</comment>
        <sha1>jfunqmh1ssfb8rs43r19w98k28gg56r</sha1>
 +      <model name="wikitext">1</model>
 +      <format mime="text/x-wiki">1</format>
        <text id="' . $this->textId2_3 . '" bytes="23" />
      </revision>
      <revision>
        </contributor>
        <comment>BackupDumperTestP2Summary4 extra</comment>
        <sha1>6o1ciaxa6pybnqprmungwofc4lv00wv</sha1>
 +      <model name="wikitext">1</model>
 +      <format mime="text/x-wiki">1</format>
        <text id="' . $this->textId2_4 . '" bytes="44" />
      </revision>
    </page>
        </contributor>
        <comment>Talk BackupDumperTestP1 Summary1</comment>
        <sha1>nktofwzd0tl192k3zfepmlzxoax1lpe</sha1>
 +      <model name="wikitext">1</model>
 +      <format mime="text/x-wiki">1</format>
        <text id="' . $this->textId4_1 . '" bytes="35" />
      </revision>
    </page>