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

Change subject: Subclass JSONContent
......................................................................


Subclass JSONContent

The custom unserializeContent is retained because even though invalid
content can't be saved, fillParserOutput is still run, causing PHP
errors.

Change-Id: I766e7c3c443c84367d301204deed3fda61d7e73f
---
M includes/content/MassMessageListContent.php
M includes/content/MassMessageListContentHandler.php
2 files changed, 9 insertions(+), 18 deletions(-)

Approvals:
  Legoktm: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/content/MassMessageListContent.php 
b/includes/content/MassMessageListContent.php
index 15f9630..c207ac3 100644
--- a/includes/content/MassMessageListContent.php
+++ b/includes/content/MassMessageListContent.php
@@ -1,6 +1,6 @@
 <?php
 
-class MassMessageListContent extends TextContent {
+class MassMessageListContent extends JSONContent {
 
        /**
         * Description wikitext
@@ -69,20 +69,6 @@
        }
 
        /**
-        * Returns a list content object with pre-save transformations applied.
-        * The implementation normalizes the JSON data.
-        * @param Title $title
-        * @param User $user
-        * @param ParserOptions $popts
-        * @return MassMessageListContent
-        */
-       public function preSaveTransform( Title $title, User $user, 
ParserOptions $popts ) {
-               $text = $this->getNativeData();
-               $pst = FormatJson::encode( FormatJson::decode( $text ) );
-               return ( $text === $pst ) ? $this : new static( $pst );
-       }
-
-       /**
         * @return string|null
         */
        public function getDescription() {
@@ -147,7 +133,7 @@
                if ( $this->decoded ) {
                        return;
                }
-               $data = FormatJson::decode( $this->getNativeData(), true );
+               $data = $this->getJsonData();
                if ( is_array( $data ) ) {
                        $this->description = array_key_exists( 'description', 
$data ) ?
                                $data['description'] : null;
diff --git a/includes/content/MassMessageListContentHandler.php 
b/includes/content/MassMessageListContentHandler.php
index 4ecdda1..d34f5bf 100644
--- a/includes/content/MassMessageListContentHandler.php
+++ b/includes/content/MassMessageListContentHandler.php
@@ -1,12 +1,17 @@
 <?php
 
-class MassMessageListContentHandler extends TextContentHandler {
+class MassMessageListContentHandler extends JSONContentHandler {
+
+       /**
+        * @var string
+        */
+       protected $contentClass = 'MassMessageListContent';
 
        /**
         * @param string $modelId
         */
        public function __construct( $modelId = 'MassMessageListContent' ) {
-               parent::__construct( $modelId, array( CONTENT_FORMAT_JSON ) );
+               parent::__construct( $modelId );
        }
 
        /**

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I766e7c3c443c84367d301204deed3fda61d7e73f
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/MassMessage
Gerrit-Branch: contenthandler
Gerrit-Owner: Wctaiwan <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to