diff --git a/autoload.php b/autoload.php index 43dadd441c5..aa2493b61f7 100644 --- a/autoload.php +++ b/autoload.php @@ -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', diff --git a/includes/CommentFormatter/RowCommentFormatter.php b/includes/CommentFormatter/RowCommentFormatter.php index a90fe34364a..99d5a2ce93d 100644 --- a/includes/CommentFormatter/RowCommentFormatter.php +++ b/includes/CommentFormatter/RowCommentFormatter.php @@ -2,7 +2,7 @@ namespace MediaWiki\CommentFormatter; -use CommentStore; +use MediaWiki\CommentStore\CommentStore; use Traversable; use Wikimedia\Rdbms\IResultWrapper; diff --git a/includes/CommentFormatter/RowCommentIterator.php b/includes/CommentFormatter/RowCommentIterator.php index 4455b737898..620a2e7ee76 100644 --- a/includes/CommentFormatter/RowCommentIterator.php +++ b/includes/CommentFormatter/RowCommentIterator.php @@ -3,8 +3,8 @@ namespace MediaWiki\CommentFormatter; use ArrayIterator; -use CommentStore; use IteratorIterator; +use MediaWiki\CommentStore\CommentStore; use TitleValue; use Traversable; diff --git a/includes/CommentStore/CommentStore.php b/includes/CommentStore/CommentStore.php new file mode 100644 index 00000000000..c47f6e49d43 --- /dev/null +++ b/includes/CommentStore/CommentStore.php @@ -0,0 +1,87 @@ + [ + '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' ); diff --git a/includes/CommentStore.php b/includes/CommentStore/CommentStoreBase.php similarity index 90% rename from includes/CommentStore.php rename to includes/CommentStore/CommentStoreBase.php index f064ec21bce..4c2e0bde899 100644 --- a/includes/CommentStore.php +++ b/includes/CommentStore/CommentStoreBase.php @@ -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 ); diff --git a/includes/CommentStoreComment.php b/includes/CommentStore/CommentStoreComment.php similarity index 95% rename from includes/CommentStoreComment.php rename to includes/CommentStore/CommentStoreComment.php index cce94b0e2ed..315cdb459c1 100644 --- a/includes/CommentStoreComment.php +++ b/includes/CommentStore/CommentStoreComment.php @@ -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' ); diff --git a/includes/EditPage.php b/includes/EditPage.php index 9eca31fc768..d9c3812dd70 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -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; diff --git a/includes/Feed/FeedUtils.php b/includes/Feed/FeedUtils.php index c0860e08f56..e82ec53a509 100644 --- a/includes/Feed/FeedUtils.php +++ b/includes/Feed/FeedUtils.php @@ -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; diff --git a/includes/MediaWikiServices.php b/includes/MediaWikiServices.php index 8f7f6fdcd49..7417a7e7734 100644 --- a/includes/MediaWikiServices.php +++ b/includes/MediaWikiServices.php @@ -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; diff --git a/includes/MergeHistory.php b/includes/MergeHistory.php index 4d606cc82d1..5754615b542 100644 --- a/includes/MergeHistory.php +++ b/includes/MergeHistory.php @@ -21,6 +21,7 @@ * @file */ +use MediaWiki\CommentStore\CommentStoreComment; use MediaWiki\Content\IContentHandlerFactory; use MediaWiki\EditPage\SpamChecker; use MediaWiki\HookContainer\HookContainer; diff --git a/includes/MovePage.php b/includes/MovePage.php index 7cefc0361fa..1efb522bcf4 100644 --- a/includes/MovePage.php +++ b/includes/MovePage.php @@ -19,6 +19,7 @@ */ use MediaWiki\Collation\CollationFactory; +use MediaWiki\CommentStore\CommentStoreComment; use MediaWiki\Config\ServiceOptions; use MediaWiki\Content\IContentHandlerFactory; use MediaWiki\EditPage\SpamChecker; diff --git a/includes/Permissions/RestrictionStore.php b/includes/Permissions/RestrictionStore.php index 8f5c0d8cf7d..789781d60fd 100644 --- a/includes/Permissions/RestrictionStore.php +++ b/includes/Permissions/RestrictionStore.php @@ -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; diff --git a/includes/ProtectionForm.php b/includes/ProtectionForm.php index ba94125a303..dc709003c86 100644 --- a/includes/ProtectionForm.php +++ b/includes/ProtectionForm.php @@ -23,6 +23,7 @@ * @file */ +use MediaWiki\CommentStore\CommentStore; use MediaWiki\HookContainer\HookRunner; use MediaWiki\MediaWikiServices; use MediaWiki\Permissions\Authority; diff --git a/includes/ResourceLoader/ResourceLoader.php b/includes/ResourceLoader/ResourceLoader.php index 9b937eedf69..442b9d8d58c 100644 --- a/includes/ResourceLoader/ResourceLoader.php +++ b/includes/ResourceLoader/ResourceLoader.php @@ -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; diff --git a/includes/Revision/MutableRevisionRecord.php b/includes/Revision/MutableRevisionRecord.php index 1bd448b0870..ed73692d724 100644 --- a/includes/Revision/MutableRevisionRecord.php +++ b/includes/Revision/MutableRevisionRecord.php @@ -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; diff --git a/includes/Revision/RevisionArchiveRecord.php b/includes/Revision/RevisionArchiveRecord.php index 4233cdd931c..7ed1378c6ed 100644 --- a/includes/Revision/RevisionArchiveRecord.php +++ b/includes/Revision/RevisionArchiveRecord.php @@ -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; diff --git a/includes/Revision/RevisionRecord.php b/includes/Revision/RevisionRecord.php index f089f772ce0..074d6becc5d 100644 --- a/includes/Revision/RevisionRecord.php +++ b/includes/Revision/RevisionRecord.php @@ -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; diff --git a/includes/Revision/RevisionStore.php b/includes/Revision/RevisionStore.php index 8f1871aca04..da06a22475b 100644 --- a/includes/Revision/RevisionStore.php +++ b/includes/Revision/RevisionStore.php @@ -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; diff --git a/includes/Revision/RevisionStoreCacheRecord.php b/includes/Revision/RevisionStoreCacheRecord.php index 246e25e7a0a..e0bb2456ad0 100644 --- a/includes/Revision/RevisionStoreCacheRecord.php +++ b/includes/Revision/RevisionStoreCacheRecord.php @@ -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; diff --git a/includes/Revision/RevisionStoreFactory.php b/includes/Revision/RevisionStoreFactory.php index dcffeb37ee7..9ec96b43fbb 100644 --- a/includes/Revision/RevisionStoreFactory.php +++ b/includes/Revision/RevisionStoreFactory.php @@ -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; diff --git a/includes/Revision/RevisionStoreRecord.php b/includes/Revision/RevisionStoreRecord.php index 1d088c032e6..e273bf1907e 100644 --- a/includes/Revision/RevisionStoreRecord.php +++ b/includes/Revision/RevisionStoreRecord.php @@ -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; diff --git a/includes/ServiceWiring.php b/includes/ServiceWiring.php index c94bd856e9e..b56f1d1cfb4 100644 --- a/includes/ServiceWiring.php +++ b/includes/ServiceWiring.php @@ -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; diff --git a/includes/Storage/Hook/BeforeRevertedTagUpdateHook.php b/includes/Storage/Hook/BeforeRevertedTagUpdateHook.php index a499f83d7dc..fcbde174f5d 100644 --- a/includes/Storage/Hook/BeforeRevertedTagUpdateHook.php +++ b/includes/Storage/Hook/BeforeRevertedTagUpdateHook.php @@ -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; diff --git a/includes/Storage/Hook/MultiContentSaveHook.php b/includes/Storage/Hook/MultiContentSaveHook.php index e3b00285148..f6f80aad58a 100644 --- a/includes/Storage/Hook/MultiContentSaveHook.php +++ b/includes/Storage/Hook/MultiContentSaveHook.php @@ -2,7 +2,7 @@ namespace MediaWiki\Storage\Hook; -use CommentStoreComment; +use MediaWiki\CommentStore\CommentStoreComment; use MediaWiki\Revision\RenderedRevision; use MediaWiki\User\UserIdentity; use Status; diff --git a/includes/Storage/Hook/PageContentSaveHook.php b/includes/Storage/Hook/PageContentSaveHook.php index d5e0593977d..15632bab171 100644 --- a/includes/Storage/Hook/PageContentSaveHook.php +++ b/includes/Storage/Hook/PageContentSaveHook.php @@ -2,8 +2,8 @@ namespace MediaWiki\Storage\Hook; -use CommentStoreComment; use Content; +use MediaWiki\CommentStore\CommentStoreComment; use StatusValue; use User; use WikiPage; diff --git a/includes/Storage/PageUpdater.php b/includes/Storage/PageUpdater.php index 68795eb915e..05c97821728 100644 --- a/includes/Storage/PageUpdater.php +++ b/includes/Storage/PageUpdater.php @@ -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; diff --git a/includes/actions/DeleteAction.php b/includes/actions/DeleteAction.php index 2dd577b94e2..49105de65d1 100644 --- a/includes/actions/DeleteAction.php +++ b/includes/actions/DeleteAction.php @@ -19,6 +19,7 @@ */ use MediaWiki\Cache\BacklinkCacheFactory; +use MediaWiki\CommentStore\CommentStore; use MediaWiki\Linker\LinkRenderer; use MediaWiki\MainConfigNames; use MediaWiki\MediaWikiServices; diff --git a/includes/actions/McrUndoAction.php b/includes/actions/McrUndoAction.php index 7c6802a3b67..ed912ca7bed 100644 --- a/includes/actions/McrUndoAction.php +++ b/includes/actions/McrUndoAction.php @@ -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; diff --git a/includes/api/ApiQueryBlocks.php b/includes/api/ApiQueryBlocks.php index c17f42dce97..98a09f81f4c 100644 --- a/includes/api/ApiQueryBlocks.php +++ b/includes/api/ApiQueryBlocks.php @@ -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; diff --git a/includes/api/ApiQueryDeletedrevs.php b/includes/api/ApiQueryDeletedrevs.php index 95cf3d6d82c..9be6f845864 100644 --- a/includes/api/ApiQueryDeletedrevs.php +++ b/includes/api/ApiQueryDeletedrevs.php @@ -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; diff --git a/includes/api/ApiQueryFilearchive.php b/includes/api/ApiQueryFilearchive.php index 3e200429273..16143b4d027 100644 --- a/includes/api/ApiQueryFilearchive.php +++ b/includes/api/ApiQueryFilearchive.php @@ -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; diff --git a/includes/api/ApiQueryLogEvents.php b/includes/api/ApiQueryLogEvents.php index 756d01daa1f..f3efc0a0aba 100644 --- a/includes/api/ApiQueryLogEvents.php +++ b/includes/api/ApiQueryLogEvents.php @@ -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; diff --git a/includes/api/ApiQueryProtectedTitles.php b/includes/api/ApiQueryProtectedTitles.php index c08d332736e..89be6a6c570 100644 --- a/includes/api/ApiQueryProtectedTitles.php +++ b/includes/api/ApiQueryProtectedTitles.php @@ -21,6 +21,7 @@ */ use MediaWiki\CommentFormatter\RowCommentFormatter; +use MediaWiki\CommentStore\CommentStore; use MediaWiki\MainConfigNames; use Wikimedia\ParamValidator\ParamValidator; use Wikimedia\ParamValidator\TypeDef\IntegerDef; diff --git a/includes/api/ApiQueryRecentChanges.php b/includes/api/ApiQueryRecentChanges.php index db613848eac..74a8682cb77 100644 --- a/includes/api/ApiQueryRecentChanges.php +++ b/includes/api/ApiQueryRecentChanges.php @@ -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; diff --git a/includes/api/ApiQueryUserContribs.php b/includes/api/ApiQueryUserContribs.php index ce341f548ea..5e25b6019b5 100644 --- a/includes/api/ApiQueryUserContribs.php +++ b/includes/api/ApiQueryUserContribs.php @@ -21,6 +21,7 @@ */ use MediaWiki\CommentFormatter\CommentFormatter; +use MediaWiki\CommentStore\CommentStore; use MediaWiki\MainConfigNames; use MediaWiki\ParamValidator\TypeDef\UserDef; use MediaWiki\Revision\RevisionRecord; diff --git a/includes/api/ApiQueryWatchlist.php b/includes/api/ApiQueryWatchlist.php index 52edf47aeff..0e6ebfc575f 100644 --- a/includes/api/ApiQueryWatchlist.php +++ b/includes/api/ApiQueryWatchlist.php @@ -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; diff --git a/includes/block/AbstractBlock.php b/includes/block/AbstractBlock.php index 1ac2347f109..1f86a1f38f4 100644 --- a/includes/block/AbstractBlock.php +++ b/includes/block/AbstractBlock.php @@ -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; diff --git a/includes/block/Block.php b/includes/block/Block.php index 83e26695d69..90abc8f6501 100644 --- a/includes/block/Block.php +++ b/includes/block/Block.php @@ -21,7 +21,7 @@ namespace MediaWiki\Block; -use CommentStoreComment; +use MediaWiki\CommentStore\CommentStoreComment; use MediaWiki\DAO\WikiAwareEntity; use MediaWiki\User\UserIdentity; diff --git a/includes/block/BlockErrorFormatter.php b/includes/block/BlockErrorFormatter.php index 1e3221bd3d6..191d1464d3e 100644 --- a/includes/block/BlockErrorFormatter.php +++ b/includes/block/BlockErrorFormatter.php @@ -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; diff --git a/includes/block/DatabaseBlock.php b/includes/block/DatabaseBlock.php index a6d73bf3a7a..800b4e78b62 100644 --- a/includes/block/DatabaseBlock.php +++ b/includes/block/DatabaseBlock.php @@ -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; diff --git a/includes/block/DatabaseBlockStore.php b/includes/block/DatabaseBlockStore.php index 5740ec00bb3..a80396fd96c 100644 --- a/includes/block/DatabaseBlockStore.php +++ b/includes/block/DatabaseBlockStore.php @@ -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; diff --git a/includes/changes/RecentChange.php b/includes/changes/RecentChange.php index 0cf335ff01e..bba141a2eda 100644 --- a/includes/changes/RecentChange.php +++ b/includes/changes/RecentChange.php @@ -21,6 +21,7 @@ */ use MediaWiki\ChangeTags\Taggable; +use MediaWiki\CommentStore\CommentStore; use MediaWiki\MainConfigNames; use MediaWiki\MediaWikiServices; use MediaWiki\Page\PageIdentity; diff --git a/includes/content/ContentHandler.php b/includes/content/ContentHandler.php index 94e6c5585db..4840fd92bbc 100644 --- a/includes/content/ContentHandler.php +++ b/includes/content/ContentHandler.php @@ -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; diff --git a/includes/export/WikiExporter.php b/includes/export/WikiExporter.php index 6a328240086..fe3d6c55b8c 100644 --- a/includes/export/WikiExporter.php +++ b/includes/export/WikiExporter.php @@ -27,6 +27,7 @@ * @defgroup Dump Dump */ +use MediaWiki\CommentStore\CommentStore; use MediaWiki\HookContainer\HookContainer; use MediaWiki\HookContainer\HookRunner; use MediaWiki\MainConfigNames; diff --git a/includes/export/XmlDumpWriter.php b/includes/export/XmlDumpWriter.php index d280ef98402..0bd51d9e991 100644 --- a/includes/export/XmlDumpWriter.php +++ b/includes/export/XmlDumpWriter.php @@ -23,6 +23,7 @@ * @file */ +use MediaWiki\CommentStore\CommentStore; use MediaWiki\HookContainer\HookRunner; use MediaWiki\MainConfigNames; use MediaWiki\MediaWikiServices; diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php index 44a03fb2098..a022f12fb83 100644 --- a/includes/filerepo/file/LocalFile.php +++ b/includes/filerepo/file/LocalFile.php @@ -18,6 +18,7 @@ * @file */ +use MediaWiki\CommentStore\CommentStoreComment; use MediaWiki\Deferred\LinksUpdate\LinksUpdate; use MediaWiki\Logger\LoggerFactory; use MediaWiki\MainConfigNames; diff --git a/includes/import/ImportableOldRevisionImporter.php b/includes/import/ImportableOldRevisionImporter.php index 66cb64e4c2d..09eba1483bc 100644 --- a/includes/import/ImportableOldRevisionImporter.php +++ b/includes/import/ImportableOldRevisionImporter.php @@ -1,5 +1,6 @@ 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 ); }