aboutsummaryrefslogtreecommitdiffstats
path: root/includes/content
diff options
context:
space:
mode:
authorJames D. Forrester <jforrester@wikimedia.org>2024-08-10 09:28:37 +0200
committerJames D. Forrester <jforrester@wikimedia.org>2024-08-10 09:28:37 +0200
commit6df7a514843314222eb600cb27c5d6585a0608ab (patch)
tree91eb7cf01c26e35f85072b654d5c60a2a0f66e96 /includes/content
parente340634274d3666336572b6ebbeddec9c6ccaae5 (diff)
downloadmediawikicore-6df7a514843314222eb600cb27c5d6585a0608ab.tar.gz
mediawikicore-6df7a514843314222eb600cb27c5d6585a0608ab.zip
Drop MessageContent, deprecated since 1.38
Change-Id: Ib53d4a04e6faa82b0ea553221e6c0c827f36017a
Diffstat (limited to 'includes/content')
-rw-r--r--includes/content/AbstractContent.php2
-rw-r--r--includes/content/MessageContent.php157
-rw-r--r--includes/content/WikitextContentHandler.php8
3 files changed, 1 insertions, 166 deletions
diff --git a/includes/content/AbstractContent.php b/includes/content/AbstractContent.php
index 7a7029fc9f5b..9d0363fa5f56 100644
--- a/includes/content/AbstractContent.php
+++ b/includes/content/AbstractContent.php
@@ -256,7 +256,7 @@ abstract class AbstractContent implements Content {
return false;
}
- // For type safety. Needed for odd cases like MessageContent using CONTENT_MODEL_WIKITEXT
+ // For type safety. Needed for odd cases like non-TextContents using CONTENT_MODEL_WIKITEXT
if ( get_class( $that ) !== get_class( $this ) ) {
return false;
}
diff --git a/includes/content/MessageContent.php b/includes/content/MessageContent.php
deleted file mode 100644
index 298a1840ecda..000000000000
--- a/includes/content/MessageContent.php
+++ /dev/null
@@ -1,157 +0,0 @@
-<?php
-/**
- * Wrapper content object allowing to handle a system message as a Content object.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @since 1.21
- *
- * @file
- * @ingroup Content
- *
- * @author Daniel Kinzler
- */
-
-use MediaWiki\Message\Message;
-
-/**
- * Wrapper allowing us to handle a system message as a Content object.
- * Note that this is generally *not* used to represent content from the
- * MediaWiki namespace.
- * MessageContent is just intended as glue for wrapping a message programmatically.
- *
- * @ingroup Content
- * @deprecated since 1.38.
- */
-class MessageContent extends AbstractContent {
-
- /**
- * @var Message
- */
- protected $mMessage;
-
- /**
- * @param Message|string $msg A Message object, or a message key.
- * @param string[]|null $params An optional array of message parameters.
- */
- public function __construct( $msg, $params = null ) {
- wfDeprecated( __CLASS__, '1.38' );
- # XXX: messages may be wikitext, html or plain text! and maybe even something else entirely.
- parent::__construct( CONTENT_MODEL_WIKITEXT );
-
- if ( is_string( $msg ) ) {
- $this->mMessage = wfMessage( $msg );
- } else {
- $this->mMessage = clone $msg;
- }
-
- if ( $params ) {
- $this->mMessage = $this->mMessage->params( $params );
- }
- }
-
- /**
- * Returns the message text. {{-transformation is done.
- *
- * @return string Unescaped message text.
- */
- public function getWikitext() {
- return $this->mMessage->text();
- }
-
- /**
- * Returns the message object, with any parameters already substituted.
- *
- * @deprecated since 1.33 use getMessage() instead.
- *
- * @return Message
- */
- public function getNativeData() {
- return $this->getMessage();
- }
-
- /**
- * Returns the message object, with any parameters already substituted.
- *
- * @since 1.33
- *
- * @return Message
- */
- public function getMessage() {
- // NOTE: Message objects are mutable. Cloning here makes MessageContent immutable.
- return clone $this->mMessage;
- }
-
- /**
- * @return string
- *
- * @see Content::getTextForSearchIndex
- */
- public function getTextForSearchIndex() {
- return $this->mMessage->plain();
- }
-
- /**
- * @return string
- *
- * @see Content::getWikitextForTransclusion
- */
- public function getWikitextForTransclusion() {
- return $this->getWikitext();
- }
-
- /**
- * @param int $maxlength Maximum length of the summary text, defaults to 250.
- *
- * @return string The summary text.
- *
- * @see Content::getTextForSummary
- */
- public function getTextForSummary( $maxlength = 250 ) {
- return mb_strcut( $this->mMessage->plain(), 0, $maxlength );
- }
-
- /**
- * @return int
- *
- * @see Content::getSize
- */
- public function getSize() {
- return strlen( $this->mMessage->plain() );
- }
-
- /**
- * @return Content A copy of this object
- *
- * @see Content::copy
- */
- public function copy() {
- // MessageContent is immutable (because getNativeData() and getMessage()
- // returns a clone of the Message object)
- return $this;
- }
-
- /**
- * @param bool|null $hasLinks
- *
- * @return bool Always false.
- *
- * @see Content::isCountable
- */
- public function isCountable( $hasLinks = null ) {
- return false;
- }
-}
diff --git a/includes/content/WikitextContentHandler.php b/includes/content/WikitextContentHandler.php
index 449d57e8521f..cd044ade1933 100644
--- a/includes/content/WikitextContentHandler.php
+++ b/includes/content/WikitextContentHandler.php
@@ -39,7 +39,6 @@ use MediaWiki\Parser\Parsoid\ParsoidParserFactory;
use MediaWiki\Revision\RevisionRecord;
use MediaWiki\Title\Title;
use MediaWiki\Title\TitleFactory;
-use MessageContent;
use ParserFactory;
use SearchEngine;
use SearchIndexField;
@@ -242,13 +241,6 @@ class WikitextContentHandler extends TextContentHandler {
*/
public function serializeContent( Content $content, $format = null ) {
$this->checkFormat( $format );
-
- // NOTE: MessageContent also uses CONTENT_MODEL_WIKITEXT, but it's not a TextContent!
- // Perhaps MessageContent should use a separate ContentHandler instead.
- if ( $content instanceof MessageContent ) {
- return $content->getMessage()->plain();
- }
-
return parent::serializeContent( $content, $format );
}