Merge branch 'Wikidata' of ssh://gerrit.wikimedia.org:29418/mediawiki/core into Wikidata
authordaniel <daniel.kinzler@wikimedia.de>
Mon, 16 Apr 2012 09:52:37 +0000 (11:52 +0200)
committerdaniel <daniel.kinzler@wikimedia.de>
Mon, 16 Apr 2012 09:52:37 +0000 (11:52 +0200)
Getting synced after Jeroen and Jens essentially rebased the core branch.

Conflicts:
includes/ContentHandler.php

Change-Id: I82efd272694ec5761fedf52f85b153a140e268e5

1  2 
includes/Article.php
includes/Content.php
includes/ContentHandler.php
includes/EditPage.php
includes/api/ApiParse.php

@@@ -210,9 -213,9 +216,9 @@@ class Article extends Page 
         * This function has side effects! Do not use this function if you
         * only want the real revision text if any.
         *
-        * @return Return the content of this revision
+        * @return Content
         */
 -   public function getContentObject() {
 +   protected function getContentObject() {
                global $wgUser;
  
                wfProfileIn( __METHOD__ );
Simple merge
@@@ -19,26 -19,29 +20,52 @@@ class MWContentSerializationException e
   */
  abstract class ContentHandler {
  
++
 +    /**
 +     * Conveniance function for getting flat text from a Content object. This shleould only
 +     * be used in the context of backwards compatibility with code that is not yet able
 +     * to handle Content objects!
 +     *
 +     * If $content is equal to null or false, this method returns the empty string.
 +     *
 +     * If $content is an instance of TextContent, this method returns the flat text as returned by $content->getnativeData().
 +     *
 +     * If $content is not a TextContent object, the bahaviour of this method depends on the global $wgContentHandlerTextFallback:
 +     * If $wgContentHandlerTextFallback is 'fail' and $content is not a TextContent object, an MWException is thrown.
 +     * If $wgContentHandlerTextFallback is 'serialize' and $content is not a TextContent object, $content->serialize()
 +     * is called to get a string form of the content.
 +     * Otherwise, this method returns null.
 +     *
 +     * @static
 +     * @param Content|null $content
 +     * @return null|string the textual form of $content, if available
 +     * @throws MWException if $content is not an instance of TextContent and $wgContentHandlerTextFallback was set to 'fail'.
 +     */
++
+       /**
+        * @abstract
+        * @param Content $content
+        * @param null $format
+        * @return String
+        */
+       public abstract function serialize( Content $content, $format = null );
+       /**
+        * TODO: calling unserialize on a ContentHandler returns a Content?!! Something looks wrong here...
+        *
+        * @abstract
+        * @param $blob String
+        * @param null $format
+        * @return Content
+        */
+       public abstract function unserialize( $blob, $format = null );
+       /**
+        * FIXME: bad method name: suggests it empties the content of an instance rather then creating a new empty one
+        */
+       public abstract function emptyContent();
++
      public static function getContentText( Content $content = null ) {
          global $wgContentHandlerTextFallback;
  
          return null;
      }
  
 +    /**
 +     * Conveniance function for creating a Content object from a given textual representation.
 +     *
 +     * $text will be deserialized into a Content object of the model specified by $modelName (or,
 +     * if that is not given, $title->getContentModelName()) using the given format.
 +     *
 +     * @static
 +     * @param $text the textual represenation, will be unserialized to create the Content object
 +     * @param Title $title the title of the page this text belongs to, required as a context for deserialization
 +     * @param null|String $modelName the model to deserialize to. If not provided, $title->getContentModelName() is used.
 +     * @param null|String $format the format to use for deserialization. If not given, the model's default format is used.
 +     *
 +     * @return Content a Content object representing $text
 +     */
      public static function makeContent( $text, Title $title, $modelName = null, $format = null ) {
-         if ( !$modelName ) {
+         if ( is_null( $modelName ) ) {
              $modelName = $title->getContentModelName();
          }
  
          return $wgContentHandlers[$modelName];
      }
  
-     # ----------------------------------------------------------------------------------------------------------
+     // ----------------------------------------------------------------------------------------------------------
 +
 +    /**
 +     * Constructor, initializing the ContentHandler instance with it's model name and a list of supported formats.
 +     * Values for the parameters are typically provided as literals by subclasses' constructors.
 +     *
 +     * @param String $modelName (use CONTENT_MODEL_XXX constants).
 +     * @param array $formats list for supported serialization formats (typically as MIME types)
 +     */
      public function __construct( $modelName, $formats ) {
          $this->mModelName = $modelName;
          $this->mSupportedFormats = $formats;
      }
  
 +    /**
 +     *
 +     * @return String the model name
 +     */
      public function getModelName() {
-         # for wikitext: wikitext; in the future: wikiast, wikidom?
-         # for wikidata: wikidata
+         // for wikitext: wikitext; in the future: wikiast, wikidom?
+         // for wikidata: wikidata
          return $this->mModelName;
      }
  
Simple merge
Simple merge