Split a base class out of CommentStore

so that extensions (i.e. CheckUser) can implement their own comment
store without having a lot of code duplication

basically the comment store version of I3a6486532f2ef36

Bug: T233004
Change-Id: Ib40f99e00a514d41776ce521baf113e46d37e9cd
This commit is contained in:
Alexander Vorwerk 2022-12-28 22:50:03 +01:00 committed by Zabe
parent 933c7db473
commit f6bd18d6c2
81 changed files with 233 additions and 90 deletions

View file

@ -269,8 +269,8 @@ $wgAutoloadLocalClasses = [
'CollapsibleFieldsetLayout' => __DIR__ . '/includes/htmlform/CollapsibleFieldsetLayout.php',
'Collation' => __DIR__ . '/includes/collation/Collation.php',
'CollationCkb' => __DIR__ . '/includes/collation/CollationCkb.php',
'CommentStore' => __DIR__ . '/includes/CommentStore.php',
'CommentStoreComment' => __DIR__ . '/includes/CommentStoreComment.php',
'CommentStore' => __DIR__ . '/includes/CommentStore/CommentStore.php',
'CommentStoreComment' => __DIR__ . '/includes/CommentStore/CommentStoreComment.php',
'CompareParserCache' => __DIR__ . '/maintenance/compareParserCache.php',
'CompareParsers' => __DIR__ . '/maintenance/compareParsers.php',
'ComposerHookHandler' => __DIR__ . '/includes/composer/ComposerHookHandler.php',
@ -976,6 +976,9 @@ $wgAutoloadLocalClasses = [
'MediaWiki\\CommentFormatter\\RowCommentFormatter' => __DIR__ . '/includes/CommentFormatter/RowCommentFormatter.php',
'MediaWiki\\CommentFormatter\\RowCommentIterator' => __DIR__ . '/includes/CommentFormatter/RowCommentIterator.php',
'MediaWiki\\CommentFormatter\\StringCommentIterator' => __DIR__ . '/includes/CommentFormatter/StringCommentIterator.php',
'MediaWiki\\CommentStore\\CommentStore' => __DIR__ . '/includes/CommentStore/CommentStore.php',
'MediaWiki\\CommentStore\\CommentStoreBase' => __DIR__ . '/includes/CommentStore/CommentStoreBase.php',
'MediaWiki\\CommentStore\\CommentStoreComment' => __DIR__ . '/includes/CommentStore/CommentStoreComment.php',
'MediaWiki\\Config\\ConfigRepository' => __DIR__ . '/includes/config/ConfigRepository.php',
'MediaWiki\\Config\\IterableConfig' => __DIR__ . '/includes/config/IterableConfig.php',
'MediaWiki\\Config\\ServiceOptions' => __DIR__ . '/includes/config/ServiceOptions.php',

View file

@ -2,7 +2,7 @@
namespace MediaWiki\CommentFormatter;
use CommentStore;
use MediaWiki\CommentStore\CommentStore;
use Traversable;
use Wikimedia\Rdbms\IResultWrapper;

View file

@ -3,8 +3,8 @@
namespace MediaWiki\CommentFormatter;
use ArrayIterator;
use CommentStore;
use IteratorIterator;
use MediaWiki\CommentStore\CommentStore;
use TitleValue;
use Traversable;

View file

@ -0,0 +1,87 @@
<?php
/**
* 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
*
* @file
*/
namespace MediaWiki\CommentStore;
use Language;
use MediaWiki\MediaWikiServices;
/**
* @defgroup CommentStore CommentStore
*
* The Comment store in MediaWiki is responsible for storing edit summaries,
* log action comments and other such short strings (referred to as "comments").
*
* The CommentStore class handles the database abstraction for reading
* and writing comments, which are represented by CommentStoreComment objects.
*
* Data is internally stored in the `comment` table.
*/
/**
* Handle database storage of comments such as edit summaries and log reasons.
*
* @ingroup CommentStore
* @since 1.30
*/
class CommentStore extends CommentStoreBase {
/**
* Define fields that use temporary tables for transitional purposes
* Array keys are field names, values are arrays with these possible fields:
* - table: Temporary table name
* - pk: Temporary table column referring to the main table's primary key
* - field: Temporary table column referring comment.comment_id
* - joinPK: Main table's primary key
* - stage: Migration stage
* - deprecatedIn: Version when using insertWithTempTable() was deprecated
*/
protected const TEMP_TABLES = [
'rev_comment' => [
'table' => 'revision_comment_temp',
'pk' => 'revcomment_rev',
'field' => 'revcomment_comment_id',
'joinPK' => 'rev_id',
'stage' => MIGRATION_OLD,
'deprecatedIn' => null,
],
];
/**
* @param Language $lang Language to use for comment truncation. Defaults
* to content language.
* @param int $stage One of the MIGRATION_* constants, or an appropriate
* combination of SCHEMA_COMPAT_* constants. Always MIGRATION_NEW for
* MediaWiki core since 1.33.
*/
public function __construct( Language $lang, $stage ) {
parent::__construct( self::TEMP_TABLES, $lang, $stage );
}
/**
* @since 1.31
* @deprecated in 1.31 Use DI to inject a CommentStore instance into your class.
* @return CommentStore
*/
public static function getStore() {
return MediaWikiServices::getInstance()->getCommentStore();
}
}
class_alias( CommentStore::class, 'CommentStore' );

View file

@ -18,29 +18,25 @@
* @file
*/
namespace MediaWiki\CommentStore;
use FormatJson;
use InvalidArgumentException;
use Language;
use LogicException;
use MediaWiki\Language\RawMessage;
use MediaWiki\MediaWikiServices;
use Message;
use OverflowException;
use stdClass;
use Wikimedia\Rdbms\IDatabase;
/**
* @defgroup CommentStore CommentStore
*
* The Comment store in MediaWiki is responsible for storing edit summaries,
* log action comments and other such short strings (referred to as "comments").
*
* The CommentStore class handles the database abstraction for reading
* and writing comments, which are represented by CommentStoreComment objects.
*
* Data is internally stored in the `comment` table.
*/
/**
/*
* Handle database storage of comments such as edit summaries and log reasons.
*
* @ingroup CommentStore
* @since 1.30
* @since 1.40
*/
class CommentStore {
class CommentStoreBase {
/**
* Maximum length of a comment in UTF-8 characters. Longer comments will be truncated.
@ -65,16 +61,7 @@ class CommentStore {
* - stage: Migration stage
* - deprecatedIn: Version when using insertWithTempTable() was deprecated
*/
protected const TEMP_TABLES = [
'rev_comment' => [
'table' => 'revision_comment_temp',
'pk' => 'revcomment_rev',
'field' => 'revcomment_comment_id',
'joinPK' => 'rev_id',
'stage' => MIGRATION_OLD,
'deprecatedIn' => null,
],
];
private $tempTables;
/**
* @var int One of the MIGRATION_* constants, or an appropriate combination
@ -91,13 +78,13 @@ class CommentStore {
private $lang;
/**
* @param array $tempTables Define fields that use temporary tables for transitional purposes
* @param Language $lang Language to use for comment truncation. Defaults
* to content language.
* @param int $stage One of the MIGRATION_* constants, or an appropriate
* combination of SCHEMA_COMPAT_* constants. Always MIGRATION_NEW for
* MediaWiki core since 1.33.
* combination of SCHEMA_COMPAT_* constants.
*/
public function __construct( Language $lang, $stage ) {
public function __construct( $tempTables, Language $lang, $stage ) {
if ( ( $stage & SCHEMA_COMPAT_WRITE_BOTH ) === 0 ) {
throw new InvalidArgumentException( '$stage must include a write mode' );
}
@ -105,17 +92,9 @@ class CommentStore {
throw new InvalidArgumentException( '$stage must include a read mode' );
}
$this->stage = $stage;
$this->tempTables = $tempTables;
$this->lang = $lang;
}
/**
* @since 1.31
* @deprecated in 1.31 Use DI to inject a CommentStore instance into your class.
* @return CommentStore
*/
public static function getStore() {
return MediaWikiServices::getInstance()->getCommentStore();
$this->stage = $stage;
}
/**
@ -145,9 +124,9 @@ class CommentStore {
$fields["{$key}_old"] = $key;
}
$tempTableStage = static::TEMP_TABLES[$key]['stage'] ?? MIGRATION_NEW;
$tempTableStage = $this->tempTables[$key]['stage'] ?? MIGRATION_NEW;
if ( $tempTableStage & SCHEMA_COMPAT_READ_OLD ) {
$fields["{$key}_pk"] = static::TEMP_TABLES[$key]['joinPK'];
$fields["{$key}_pk"] = $this->tempTables[$key]['joinPK'];
}
if ( $tempTableStage & SCHEMA_COMPAT_READ_NEW ) {
$fields["{$key}_id"] = "{$key}_id";
@ -186,9 +165,9 @@ class CommentStore {
} else { // READ_BOTH or READ_NEW
$join = ( $this->stage & SCHEMA_COMPAT_READ_OLD ) ? 'LEFT JOIN' : 'JOIN';
$tempTableStage = static::TEMP_TABLES[$key]['stage'] ?? MIGRATION_NEW;
$tempTableStage = $this->tempTables[$key]['stage'] ?? MIGRATION_NEW;
if ( $tempTableStage & SCHEMA_COMPAT_READ_OLD ) {
$t = static::TEMP_TABLES[$key];
$t = $this->tempTables[$key];
$alias = "temp_$key";
$tables[$alias] = $t['table'];
$joins[$alias] = [ $join, "{$alias}.{$t['pk']} = {$t['joinPK']}" ];
@ -196,7 +175,7 @@ class CommentStore {
$joinField = "{$alias}.{$t['field']}";
} else {
// Nothing hits this code path for now, but will in the future when we set
// static::TEMP_TABLES['rev_comment']['stage'] to MIGRATION_WRITE_NEW while
// $this->tempTables['rev_comment']['stage'] to MIGRATION_WRITE_NEW while
// merging revision_comment_temp into revision.
// @codeCoverageIgnoreStart
$joins[$alias][0] = 'LEFT JOIN';
@ -262,7 +241,7 @@ class CommentStore {
}
$data = null;
} else {
$tempTableStage = static::TEMP_TABLES[$key]['stage'] ?? MIGRATION_NEW;
$tempTableStage = $this->tempTables[$key]['stage'] ?? MIGRATION_NEW;
$row2 = null;
if ( ( $tempTableStage & SCHEMA_COMPAT_READ_NEW ) && array_key_exists( "{$key}_id", $row ) ) {
if ( !$db ) {
@ -287,7 +266,7 @@ class CommentStore {
. "does have fields for getCommentLegacy()"
);
}
$t = static::TEMP_TABLES[$key];
$t = $this->tempTables[$key];
$id = $row["{$key}_pk"];
$row2 = $db->newSelectQueryBuilder()
->select( [ 'comment_id', 'comment_text', 'comment_data' ] )
@ -495,9 +474,9 @@ class CommentStore {
}
if ( $this->stage & SCHEMA_COMPAT_WRITE_NEW ) {
$tempTableStage = static::TEMP_TABLES[$key]['stage'] ?? MIGRATION_NEW;
$tempTableStage = $this->tempTables[$key]['stage'] ?? MIGRATION_NEW;
if ( $tempTableStage & SCHEMA_COMPAT_WRITE_OLD ) {
$t = static::TEMP_TABLES[$key];
$t = $this->tempTables[$key];
$func = __METHOD__;
$commentId = $comment->id;
$callback = static function ( $id ) use ( $dbw, $commentId, $t, $func ) {
@ -541,7 +520,7 @@ class CommentStore {
// @codeCoverageIgnoreEnd
}
$tempTableStage = static::TEMP_TABLES[$key]['stage'] ?? MIGRATION_NEW;
$tempTableStage = $this->tempTables[$key]['stage'] ?? MIGRATION_NEW;
if ( $tempTableStage & SCHEMA_COMPAT_WRITE_OLD ) {
throw new InvalidArgumentException( "Must use insertWithTempTable() for $key" );
}
@ -577,11 +556,10 @@ class CommentStore {
// @codeCoverageIgnoreEnd
}
if ( !isset( static::TEMP_TABLES[$key] ) ) {
if ( !isset( $this->tempTables[$key] ) ) {
throw new InvalidArgumentException( "Must use insert() for $key" );
} elseif ( isset( static::TEMP_TABLES[$key]['deprecatedIn'] ) ) {
// @phan-suppress-next-line PhanTypeMismatchArgument 'deprecatedIn' is usually string
wfDeprecated( __METHOD__ . " for $key", static::TEMP_TABLES[$key]['deprecatedIn'] );
} elseif ( isset( $this->tempTables[$key]['deprecatedIn'] ) ) {
wfDeprecated( __METHOD__ . " for $key", $this->tempTables[$key]['deprecatedIn'] );
}
[ $fields, $callback ] = $this->insertInternal( $dbw, $key, $comment, $data );

View file

@ -18,8 +18,12 @@
* @file
*/
namespace MediaWiki\CommentStore;
use InvalidArgumentException;
use MediaWiki\Language\RawMessage;
use MediaWiki\MediaWikiServices;
use Message;
/**
* Value object for a comment stored by CommentStore.
@ -91,3 +95,5 @@ class CommentStoreComment {
}
}
}
class_alias( CommentStoreComment::class, 'CommentStoreComment' );

View file

@ -22,6 +22,8 @@
use MediaWiki\Block\DatabaseBlock;
use MediaWiki\Cache\LinkBatchFactory;
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\CommentStore\CommentStoreComment;
use MediaWiki\Content\IContentHandlerFactory;
use MediaWiki\EditPage\Constraint\AccidentalRecreationConstraint;
use MediaWiki\EditPage\Constraint\AutoSummaryMissingSummaryConstraint;

View file

@ -23,10 +23,10 @@
namespace MediaWiki\Feed;
use CommentStore;
use DerivativeContext;
use Html;
use LogFormatter;
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\MainConfigNames;
use MediaWiki\MediaWikiServices;
use MediaWiki\Revision\RevisionRecord;

View file

@ -22,7 +22,6 @@ namespace MediaWiki;
use BagOStuff;
use CentralIdLookup;
use CommentStore;
use Config;
use ConfigFactory;
use ConfiguredReadOnlyMode;
@ -60,6 +59,7 @@ use MediaWiki\Cache\LinkBatchFactory;
use MediaWiki\Collation\CollationFactory;
use MediaWiki\CommentFormatter\CommentFormatter;
use MediaWiki\CommentFormatter\RowCommentFormatter;
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\Config\ConfigRepository;
use MediaWiki\Content\IContentHandlerFactory;
use MediaWiki\Content\Renderer\ContentRenderer;

View file

@ -21,6 +21,7 @@
* @file
*/
use MediaWiki\CommentStore\CommentStoreComment;
use MediaWiki\Content\IContentHandlerFactory;
use MediaWiki\EditPage\SpamChecker;
use MediaWiki\HookContainer\HookContainer;

View file

@ -19,6 +19,7 @@
*/
use MediaWiki\Collation\CollationFactory;
use MediaWiki\CommentStore\CommentStoreComment;
use MediaWiki\Config\ServiceOptions;
use MediaWiki\Content\IContentHandlerFactory;
use MediaWiki\EditPage\SpamChecker;

View file

@ -2,11 +2,11 @@
namespace MediaWiki\Permissions;
use CommentStore;
use DBAccessObjectUtils;
use IDBAccessObject;
use LinkCache;
use MediaWiki\Cache\CacheKeyHelper;
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\Config\ServiceOptions;
use MediaWiki\HookContainer\HookContainer;
use MediaWiki\HookContainer\HookRunner;

View file

@ -23,6 +23,7 @@
* @file
*/
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\HookContainer\HookRunner;
use MediaWiki\MediaWikiServices;
use MediaWiki\Permissions\Authority;

View file

@ -23,7 +23,6 @@
namespace MediaWiki\ResourceLoader;
use BagOStuff;
use CommentStore;
use Config;
use DeferredUpdates;
use Exception;
@ -34,6 +33,7 @@ use Html;
use HttpStatus;
use InvalidArgumentException;
use Less_Parser;
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\HookContainer\HookContainer;
use MediaWiki\MainConfigNames;
use MediaWiki\MediaWikiServices;

View file

@ -22,9 +22,9 @@
namespace MediaWiki\Revision;
use CommentStoreComment;
use Content;
use InvalidArgumentException;
use MediaWiki\CommentStore\CommentStoreComment;
use MediaWiki\Page\PageIdentity;
use MediaWiki\Storage\RevisionSlotsUpdate;
use MediaWiki\User\UserIdentity;

View file

@ -22,7 +22,7 @@
namespace MediaWiki\Revision;
use CommentStoreComment;
use MediaWiki\CommentStore\CommentStoreComment;
use MediaWiki\Page\PageIdentity;
use MediaWiki\Permissions\Authority;
use MediaWiki\User\UserIdentity;

View file

@ -22,9 +22,9 @@
namespace MediaWiki\Revision;
use CommentStoreComment;
use Content;
use InvalidArgumentException;
use MediaWiki\CommentStore\CommentStoreComment;
use MediaWiki\DAO\WikiAwareEntity;
use MediaWiki\DAO\WikiAwareEntityTrait;
use MediaWiki\Linker\LinkTarget;

View file

@ -26,14 +26,14 @@
namespace MediaWiki\Revision;
use BagOStuff;
use CommentStore;
use CommentStoreComment;
use Content;
use DBAccessObjectUtils;
use FallbackContent;
use IDBAccessObject;
use InvalidArgumentException;
use LogicException;
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\CommentStore\CommentStoreComment;
use MediaWiki\Content\IContentHandlerFactory;
use MediaWiki\DAO\WikiAwareEntity;
use MediaWiki\HookContainer\HookContainer;

View file

@ -22,7 +22,7 @@
namespace MediaWiki\Revision;
use CommentStoreComment;
use MediaWiki\CommentStore\CommentStoreComment;
use MediaWiki\Page\PageIdentity;
use MediaWiki\Permissions\Authority;
use MediaWiki\User\UserIdentity;

View file

@ -27,7 +27,7 @@
namespace MediaWiki\Revision;
use BagOStuff;
use CommentStore;
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\Content\IContentHandlerFactory;
use MediaWiki\HookContainer\HookContainer;
use MediaWiki\Page\PageStoreFactory;

View file

@ -22,8 +22,8 @@
namespace MediaWiki\Revision;
use CommentStoreComment;
use InvalidArgumentException;
use MediaWiki\CommentStore\CommentStoreComment;
use MediaWiki\Page\PageIdentity;
use MediaWiki\Permissions\Authority;
use MediaWiki\User\UserIdentity;

View file

@ -63,6 +63,7 @@ use MediaWiki\Collation\CollationFactory;
use MediaWiki\CommentFormatter\CommentFormatter;
use MediaWiki\CommentFormatter\CommentParserFactory;
use MediaWiki\CommentFormatter\RowCommentFormatter;
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\Config\ConfigRepository;
use MediaWiki\Config\ServiceOptions;
use MediaWiki\Content\ContentHandlerFactory;

View file

@ -2,7 +2,7 @@
namespace MediaWiki\Storage\Hook;
use CommentStoreComment;
use MediaWiki\CommentStore\CommentStoreComment;
use MediaWiki\Revision\RevisionRecord;
use MediaWiki\Storage\EditResult;
use MediaWiki\User\UserIdentity;

View file

@ -2,7 +2,7 @@
namespace MediaWiki\Storage\Hook;
use CommentStoreComment;
use MediaWiki\CommentStore\CommentStoreComment;
use MediaWiki\Revision\RenderedRevision;
use MediaWiki\User\UserIdentity;
use Status;

View file

@ -2,8 +2,8 @@
namespace MediaWiki\Storage\Hook;
use CommentStoreComment;
use Content;
use MediaWiki\CommentStore\CommentStoreComment;
use StatusValue;
use User;
use WikiPage;

View file

@ -22,13 +22,13 @@ namespace MediaWiki\Storage;
use AtomicSectionUpdate;
use ChangeTags;
use CommentStoreComment;
use Content;
use ContentHandler;
use DeferredUpdates;
use InvalidArgumentException;
use LogicException;
use ManualLogEntry;
use MediaWiki\CommentStore\CommentStoreComment;
use MediaWiki\Config\ServiceOptions;
use MediaWiki\Content\IContentHandlerFactory;
use MediaWiki\Content\ValidationParams;

View file

@ -19,6 +19,7 @@
*/
use MediaWiki\Cache\BacklinkCacheFactory;
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\Linker\LinkRenderer;
use MediaWiki\MainConfigNames;
use MediaWiki\MediaWikiServices;

View file

@ -6,6 +6,8 @@
*/
use MediaWiki\CommentFormatter\CommentFormatter;
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\CommentStore\CommentStoreComment;
use MediaWiki\Linker\Linker;
use MediaWiki\MainConfigNames;
use MediaWiki\Permissions\PermissionStatus;

View file

@ -23,6 +23,7 @@
use MediaWiki\Block\BlockActionInfo;
use MediaWiki\Block\BlockRestrictionStore;
use MediaWiki\Block\Restriction\PageRestriction;
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\MainConfigNames;
use MediaWiki\ParamValidator\TypeDef\UserDef;
use Wikimedia\IPUtils;

View file

@ -22,6 +22,7 @@
use MediaWiki\Cache\LinkBatchFactory;
use MediaWiki\CommentFormatter\RowCommentFormatter;
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\ParamValidator\TypeDef\UserDef;
use MediaWiki\Revision\RevisionRecord;
use MediaWiki\Revision\RevisionStore;

View file

@ -26,6 +26,7 @@
use MediaWiki\CommentFormatter\CommentFormatter;
use MediaWiki\CommentFormatter\CommentItem;
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\Revision\RevisionRecord;
use Wikimedia\ParamValidator\ParamValidator;
use Wikimedia\ParamValidator\TypeDef\IntegerDef;

View file

@ -22,6 +22,7 @@
use MediaWiki\CommentFormatter\CommentFormatter;
use MediaWiki\CommentFormatter\RowCommentFormatter;
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\MainConfigNames;
use MediaWiki\ParamValidator\TypeDef\NamespaceDef;
use MediaWiki\ParamValidator\TypeDef\UserDef;

View file

@ -21,6 +21,7 @@
*/
use MediaWiki\CommentFormatter\RowCommentFormatter;
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\MainConfigNames;
use Wikimedia\ParamValidator\ParamValidator;
use Wikimedia\ParamValidator\TypeDef\IntegerDef;

View file

@ -21,6 +21,7 @@
*/
use MediaWiki\CommentFormatter\RowCommentFormatter;
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\MainConfigNames;
use MediaWiki\ParamValidator\TypeDef\NamespaceDef;
use MediaWiki\ParamValidator\TypeDef\UserDef;

View file

@ -21,6 +21,7 @@
*/
use MediaWiki\CommentFormatter\CommentFormatter;
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\MainConfigNames;
use MediaWiki\ParamValidator\TypeDef\UserDef;
use MediaWiki\Revision\RevisionRecord;

View file

@ -21,6 +21,7 @@
*/
use MediaWiki\CommentFormatter\CommentFormatter;
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\Linker\LinkTarget;
use MediaWiki\ParamValidator\TypeDef\UserDef;
use MediaWiki\Revision\RevisionRecord;

View file

@ -20,10 +20,10 @@
namespace MediaWiki\Block;
use CommentStoreComment;
use DeprecationHelper;
use IContextSource;
use InvalidArgumentException;
use MediaWiki\CommentStore\CommentStoreComment;
use MediaWiki\DAO\WikiAwareEntityTrait;
use MediaWiki\MainConfigNames;
use MediaWiki\MediaWikiServices;

View file

@ -21,7 +21,7 @@
namespace MediaWiki\Block;
use CommentStoreComment;
use MediaWiki\CommentStore\CommentStoreComment;
use MediaWiki\DAO\WikiAwareEntity;
use MediaWiki\User\UserIdentity;

View file

@ -20,8 +20,8 @@
namespace MediaWiki\Block;
use CommentStoreComment;
use Language;
use MediaWiki\CommentStore\CommentStoreComment;
use MediaWiki\HookContainer\HookContainer;
use MediaWiki\HookContainer\HookRunner;
use MediaWiki\Page\PageReferenceValue;

View file

@ -22,7 +22,6 @@
namespace MediaWiki\Block;
use CommentStore;
use Hooks;
use Html;
use InvalidArgumentException;
@ -30,6 +29,7 @@ use MediaWiki\Block\Restriction\ActionRestriction;
use MediaWiki\Block\Restriction\NamespaceRestriction;
use MediaWiki\Block\Restriction\PageRestriction;
use MediaWiki\Block\Restriction\Restriction;
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\MainConfigNames;
use MediaWiki\MediaWikiServices;
use MediaWiki\User\UserIdentity;

View file

@ -23,9 +23,9 @@
namespace MediaWiki\Block;
use AutoCommitUpdate;
use CommentStore;
use DeferredUpdates;
use InvalidArgumentException;
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\Config\ServiceOptions;
use MediaWiki\HookContainer\HookContainer;
use MediaWiki\HookContainer\HookRunner;

View file

@ -21,6 +21,7 @@
*/
use MediaWiki\ChangeTags\Taggable;
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\MainConfigNames;
use MediaWiki\MediaWikiServices;
use MediaWiki\Page\PageIdentity;

View file

@ -26,6 +26,7 @@
* @author Daniel Kinzler
*/
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\Content\Renderer\ContentParseParams;
use MediaWiki\Content\Transform\PreloadTransformParams;
use MediaWiki\Content\Transform\PreSaveTransformParams;

View file

@ -27,6 +27,7 @@
* @defgroup Dump Dump
*/
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\HookContainer\HookContainer;
use MediaWiki\HookContainer\HookRunner;
use MediaWiki\MainConfigNames;

View file

@ -23,6 +23,7 @@
* @file
*/
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\HookContainer\HookRunner;
use MediaWiki\MainConfigNames;
use MediaWiki\MediaWikiServices;

View file

@ -18,6 +18,7 @@
* @file
*/
use MediaWiki\CommentStore\CommentStoreComment;
use MediaWiki\Deferred\LinksUpdate\LinksUpdate;
use MediaWiki\Logger\LoggerFactory;
use MediaWiki\MainConfigNames;

View file

@ -1,5 +1,6 @@
<?php
use MediaWiki\CommentStore\CommentStoreComment;
use MediaWiki\MediaWikiServices;
use MediaWiki\Page\WikiPageFactory;
use MediaWiki\Revision\MutableRevisionRecord;

View file

@ -23,6 +23,8 @@
* @file
* @ingroup SpecialPage
*/
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\MediaWikiServices;
use MediaWiki\Revision\MutableRevisionSlots;
use MediaWiki\Revision\SlotRecord;

View file

@ -23,6 +23,7 @@
* @since 1.19
*/
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\Logger\LoggerFactory;
use MediaWiki\MediaWikiServices;
use MediaWiki\User\UserIdentity;

View file

@ -24,6 +24,7 @@
*/
use MediaWiki\ChangeTags\Taggable;
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\Linker\LinkTarget;
use MediaWiki\MediaWikiServices;
use MediaWiki\Page\PageReference;

View file

@ -23,6 +23,7 @@
* @since 1.19
*/
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\Logger\LoggerFactory;
use MediaWiki\MediaWikiServices;
use MediaWiki\User\UserIdentity;

View file

@ -5,7 +5,6 @@ namespace MediaWiki\Page;
use BadMethodCallException;
use BagOStuff;
use ChangeTags;
use CommentStore;
use Content;
use DeferrableUpdate;
use DeferredUpdates;
@ -15,6 +14,7 @@ use JobQueueGroup;
use LogicException;
use ManualLogEntry;
use MediaWiki\Cache\BacklinkCacheFactory;
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\Config\ServiceOptions;
use MediaWiki\Deferred\LinksUpdate\LinksDeletionUpdate;
use MediaWiki\Deferred\LinksUpdate\LinksUpdate;

View file

@ -22,12 +22,12 @@
namespace MediaWiki\Page;
use BagOStuff;
use CommentStore;
use Config;
use ContentModelChange;
use JobQueueGroup;
use MediaWiki\Cache\BacklinkCacheFactory;
use MediaWiki\Collation\CollationFactory;
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\Config\ServiceOptions;
use MediaWiki\Content\IContentHandlerFactory;
use MediaWiki\EditPage\SpamChecker;

View file

@ -20,8 +20,8 @@
namespace MediaWiki\Page;
use CommentStoreComment;
use ManualLogEntry;
use MediaWiki\CommentStore\CommentStoreComment;
use MediaWiki\Config\ServiceOptions;
use MediaWiki\HookContainer\HookContainer;
use MediaWiki\HookContainer\HookRunner;

View file

@ -18,6 +18,8 @@
* @file
*/
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\CommentStore\CommentStoreComment;
use MediaWiki\DAO\WikiAwareEntityTrait;
use MediaWiki\Edit\PreparedEdit;
use MediaWiki\HookContainer\ProtectedHookAccessorTrait;

View file

@ -19,6 +19,7 @@
* @ingroup RevisionDelete
*/
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\MediaWikiServices;
use MediaWiki\Revision\RevisionRecord;

View file

@ -19,6 +19,7 @@
* @ingroup RevisionDelete
*/
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\Page\PageIdentity;
use MediaWiki\Revision\RevisionRecord;
use Wikimedia\Rdbms\IDatabase;

View file

@ -26,6 +26,7 @@ use MediaWiki\Block\BlockRestrictionStore;
use MediaWiki\Block\BlockUtils;
use MediaWiki\Cache\LinkBatchFactory;
use MediaWiki\CommentFormatter\RowCommentFormatter;
use MediaWiki\CommentStore\CommentStore;
use Wikimedia\Rdbms\ILoadBalancer;
/**

View file

@ -30,6 +30,7 @@ use MediaWiki\Block\DatabaseBlock;
use MediaWiki\Block\Restriction\ActionRestriction;
use MediaWiki\Block\Restriction\NamespaceRestriction;
use MediaWiki\Block\Restriction\PageRestriction;
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\MainConfigNames;
use MediaWiki\MediaWikiServices;
use MediaWiki\Page\PageReference;

View file

@ -27,6 +27,7 @@ use MediaWiki\Block\BlockUtils;
use MediaWiki\Block\DatabaseBlock;
use MediaWiki\Cache\LinkBatchFactory;
use MediaWiki\CommentFormatter\RowCommentFormatter;
use MediaWiki\CommentStore\CommentStore;
use Wikimedia\IPUtils;
use Wikimedia\Rdbms\IDatabase;
use Wikimedia\Rdbms\ILoadBalancer;

View file

@ -1,5 +1,6 @@
<?php
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\Content\IContentHandlerFactory;
use MediaWiki\EditPage\SpamChecker;
use MediaWiki\Language\RawMessage;

View file

@ -23,6 +23,7 @@
use MediaWiki\Block\DatabaseBlock;
use MediaWiki\CommentFormatter\CommentFormatter;
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\MainConfigNames;
use MediaWiki\Permissions\PermissionManager;
use MediaWiki\Revision\RevisionFactory;

View file

@ -19,6 +19,7 @@
* @ingroup SpecialPage
*/
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\Permissions\PermissionManager;
/**

View file

@ -22,6 +22,7 @@
*/
use MediaWiki\CommentFormatter\CommentFormatter;
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\User\UserNamePrefixSearch;
use MediaWiki\User\UserNameUtils;
use MediaWiki\User\UserRigorOptions;

View file

@ -22,6 +22,7 @@
*/
use MediaWiki\Cache\LinkBatchFactory;
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\Content\IContentHandlerFactory;
use MediaWiki\MainConfigNames;
use MediaWiki\Page\MovePageFactory;

View file

@ -23,6 +23,7 @@
use MediaWiki\Cache\LinkBatchFactory;
use MediaWiki\CommentFormatter\CommentFormatter;
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\Content\IContentHandlerFactory;
use MediaWiki\Feed\FeedItem;
use MediaWiki\Linker\Linker;

View file

@ -23,6 +23,7 @@
use MediaWiki\Cache\LinkBatchFactory;
use MediaWiki\CommentFormatter\RowCommentFormatter;
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\MainConfigNames;
use MediaWiki\Permissions\RestrictionStore;
use Wikimedia\Rdbms\ILoadBalancer;

View file

@ -21,6 +21,7 @@
* @ingroup SpecialPage
*/
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\Permissions\PermissionManager;
use MediaWiki\Revision\RevisionRecord;

View file

@ -21,6 +21,7 @@
* @ingroup SpecialPage
*/
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\MainConfigNames;
/**

View file

@ -23,6 +23,7 @@
use MediaWiki\Cache\LinkBatchFactory;
use MediaWiki\CommentFormatter\CommentFormatter;
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\Content\IContentHandlerFactory;
use MediaWiki\Linker\Linker;
use MediaWiki\MainConfigNames;

View file

@ -21,6 +21,7 @@
* @ingroup SpecialPage
*/
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\Linker\Linker;
use MediaWiki\MainConfigNames;
use MediaWiki\MediaWikiServices;

View file

@ -18,6 +18,7 @@
* @file
*/
use MediaWiki\CommentStore\CommentStoreComment;
use MediaWiki\HookContainer\ProtectedHookAccessorTrait;
use MediaWiki\MediaWikiServices;
use MediaWiki\Page\PageIdentity;

View file

@ -28,6 +28,7 @@ use MediaWiki\Block\Restriction\PageRestriction;
use MediaWiki\Block\Restriction\Restriction;
use MediaWiki\Cache\LinkBatchFactory;
use MediaWiki\CommentFormatter\RowCommentFormatter;
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\Linker\Linker;
use MediaWiki\Linker\LinkRenderer;
use MediaWiki\MainConfigNames;

View file

@ -20,6 +20,7 @@
*/
use MediaWiki\CommentFormatter\CommentFormatter;
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\HookContainer\HookContainer;
use MediaWiki\HookContainer\HookRunner;
use MediaWiki\Linker\Linker;

View file

@ -20,6 +20,7 @@
*/
use MediaWiki\CommentFormatter\CommentFormatter;
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\Linker\LinkRenderer;
use MediaWiki\MainConfigNames;
use MediaWiki\User\UserNameUtils;

View file

@ -21,6 +21,7 @@
use MediaWiki\Cache\LinkBatchFactory;
use MediaWiki\CommentFormatter\RowCommentFormatter;
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\Linker\Linker;
use MediaWiki\Linker\LinkRenderer;
use Wikimedia\Rdbms\ILoadBalancer;

View file

@ -1,5 +1,6 @@
<?php
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\HookContainer\HookContainer;
use MediaWiki\HookContainer\HookRunner;
use MediaWiki\Linker\LinkTarget;

View file

@ -21,6 +21,7 @@
* @ingroup Maintenance
*/
use MediaWiki\CommentStore\CommentStoreComment;
use MediaWiki\Language\RawMessage;
use MediaWiki\MediaWikiServices;
use MediaWiki\Revision\SlotRecord;

View file

@ -21,6 +21,7 @@
* @ingroup Maintenance
*/
use MediaWiki\CommentStore\CommentStoreComment;
use MediaWiki\MediaWikiServices;
use MediaWiki\Revision\SlotRecord;
use Wikimedia\Rdbms\DBQueryError;

View file

@ -25,6 +25,7 @@
require_once __DIR__ . '/Maintenance.php';
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\MediaWikiServices;
use MediaWiki\User\ActorMigration;
use Wikimedia\Rdbms\IDatabase;

View file

@ -1,5 +1,7 @@
<?php
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\CommentStore\CommentStoreBase;
use MediaWiki\Language\RawMessage;
use Wikimedia\Rdbms\IMaintainableDatabase;
@ -41,7 +43,7 @@ class CommentStoreTest extends MediaWikiLangTestCase {
$lang->method( 'truncateForVisual' )->willReturnCallback( static function ( $str, $len ) {
return mb_strlen( $str ) > $len ? mb_substr( $str, 0, $len - 3 ) . '...' : $str;
} );
return new class( $lang, $stage ) extends CommentStore {
return new class( $lang, $stage ) extends CommentStoreBase {
protected const TEMP_TABLES = [
'rev_comment' => [
'table' => 'revision_comment_temp',
@ -60,6 +62,10 @@ class CommentStoreTest extends MediaWikiLangTestCase {
'deprecatedIn' => null,
],
];
public function __construct( $lang, $stage ) {
parent::__construct( self::TEMP_TABLES, $lang, $stage );
}
};
}
@ -806,16 +812,24 @@ class CommentStoreTest extends MediaWikiLangTestCase {
*/
public function testInsertWithTempTableDeprecated( $stage ) {
$lang = $this->getServiceContainer()->getContentLanguage();
$store = new class( $lang, $stage ) extends CommentStore {
protected const TEMP_TABLES = [
'ipb_reason' => [
'stage' => MIGRATION_NEW,
'deprecatedIn' => '1.30',
],
];
$store = new class( $lang, $stage ) extends CommentStoreBase {
public function __construct( $lang, $stage ) {
parent::__construct(
[
'ipb_reason' => [
'stage' => MIGRATION_NEW,
'deprecatedIn' => '1.30',
],
],
$lang,
$stage
);
}
};
$this->hideDeprecated( 'CommentStore::insertWithTempTable for ipb_reason' );
$this->hideDeprecated(
'MediaWiki\\CommentStore\\CommentStoreBase::insertWithTempTable for ipb_reason'
);
[ $fields, $callback ] = $store->insertWithTempTable( $this->db, 'ipb_reason', 'foo' );
$this->assertIsCallable( $callback );
}