X-Git-Url: http://git.cyclocoop.org/%28?a=blobdiff_plain;f=includes%2FCommentStore.php;h=1a60bb741266ae3251e95593cc9ae32f0890a9b1;hb=333eaea7f7bf2d7dcaed1e9da62477a5245cfc72;hp=1be79510cb7e87da5f5ec51b5f3ce7c3b161e5ab;hpb=9c0eeb1a2d985f77134385975bf611ddc2bb8c7b;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/CommentStore.php b/includes/CommentStore.php index 1be79510cb..1a60bb7412 100644 --- a/includes/CommentStore.php +++ b/includes/CommentStore.php @@ -70,11 +70,7 @@ class CommentStore { 'deprecatedIn' => null, ], 'img_description' => [ - 'table' => 'image_comment_temp', - 'pk' => 'imgcomment_name', - 'field' => 'imgcomment_description_id', - 'joinPK' => 'img_name', - 'stage' => MIGRATION_WRITE_NEW, + 'stage' => MIGRATION_NEW, 'deprecatedIn' => '1.32', ], ]; @@ -86,7 +82,11 @@ class CommentStore { */ protected $key = null; - /** @var int One of the MIGRATION_* constants */ + /** + * @var int One of the MIGRATION_* constants + * @todo Deprecate and remove once extensions seem unlikely to need to use + * it for migration anymore. + */ protected $stage; /** @var array[] Cache for `self::getJoin()` */ @@ -98,7 +98,8 @@ class CommentStore { /** * @param Language $lang Language to use for comment truncation. Defaults * to content language. - * @param int $migrationStage One of the MIGRATION_* constants + * @param int $migrationStage One of the MIGRATION_* constants. Always + * MIGRATION_NEW for MediaWiki core since 1.33. */ public function __construct( Language $lang, $migrationStage ) { $this->stage = $migrationStage; @@ -113,10 +114,10 @@ class CommentStore { * @return CommentStore */ public static function newKey( $key ) { - global $wgCommentTableSchemaMigrationStage; wfDeprecated( __METHOD__, '1.31' ); - $store = new CommentStore( MediaWikiServices::getInstance()->getContentLanguage(), - $wgCommentTableSchemaMigrationStage ); + $store = new CommentStore( + MediaWikiServices::getInstance()->getContentLanguage(), MIGRATION_NEW + ); $store->key = $key; return $store; } @@ -226,8 +227,14 @@ class CommentStore { if ( $tempTableStage === MIGRATION_OLD ) { $joinField = "{$alias}.{$t['field']}"; } else { + // Nothing hits this code path for now, but will in the future when we set + // $this->tempTables['rev_comment']['stage'] to MIGRATION_WRITE_NEW while + // merging revision_comment_temp into revision. + // @codeCoverageIgnoreStart $joins[$alias][0] = 'LEFT JOIN'; $joinField = "(CASE WHEN {$key}_id != 0 THEN {$key}_id ELSE {$alias}.{$t['field']} END)"; + throw new LogicException( 'Nothing should reach this code path at this time' ); + // @codeCoverageIgnoreEnd } } else { $joinField = "{$key}_id"; @@ -349,14 +356,13 @@ class CommentStore { $msg = null; if ( $data !== null ) { - $data = FormatJson::decode( $data ); - if ( !is_object( $data ) ) { + $data = FormatJson::decode( $data, true ); + if ( !is_array( $data ) ) { // @codeCoverageIgnoreStart wfLogWarning( "Invalid JSON object in comment: $data" ); $data = null; // @codeCoverageIgnoreEnd } else { - $data = (array)$data; if ( isset( $data['_message'] ) ) { $msg = self::decodeMessage( $data['_message'] ) ->setInterfaceMessageFlag( true );