Thiemo Mättig (WMDE) has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/340109 )
Change subject: Make ChangeRow::getInfo public ...................................................................... Make ChangeRow::getInfo public This is only one step in a series of many more patches. The plan is to remove this method later in favor of dedicated setters and getters for each individual field. But for now I'm focusing on the problematic setField(s) and getField(s). Change-Id: I5d1ec960fc2870eb88a8b441c6500a56b3b37a4a --- M client/includes/Changes/ChangeHandler.php M client/includes/Changes/ChangeRunCoalescer.php M client/includes/RecentChanges/RecentChangeFactory.php M lib/includes/Changes/ChangeRow.php M lib/tests/phpunit/Changes/TestChanges.php M repo/includes/Store/Sql/SqlChangeStore.php 6 files changed, 11 insertions(+), 19 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/09/340109/1 diff --git a/client/includes/Changes/ChangeHandler.php b/client/includes/Changes/ChangeHandler.php index 14c7b52..8f98809 100644 --- a/client/includes/Changes/ChangeHandler.php +++ b/client/includes/Changes/ChangeHandler.php @@ -286,9 +286,8 @@ * @return string */ private function getChangeIdForLog( Change $change ) { - if ( $change instanceof EntityChange && $change->hasField( 'info' ) ) { - //@todo: add getFields() to the Change interface, or provide getters! - $info = $change->getField( 'info' ); + if ( $change instanceof EntityChange ) { + $info = $change->getInfo(); if ( isset( $info['change-ids'] ) ) { return implode( '|', $info['change-ids'] ); diff --git a/client/includes/Changes/ChangeRunCoalescer.php b/client/includes/Changes/ChangeRunCoalescer.php index 5195404..b6df856 100644 --- a/client/includes/Changes/ChangeRunCoalescer.php +++ b/client/includes/Changes/ChangeRunCoalescer.php @@ -187,7 +187,7 @@ //FIXME: size before & size after ) ); - $info = $change->hasField( 'info' ) ? $change->getField( 'info' ) : array(); + $info = $change->getInfo(); $info['change-ids'] = $ids; $info['changes'] = $changes; $change->setField( 'info', $info ); diff --git a/client/includes/RecentChanges/RecentChangeFactory.php b/client/includes/RecentChanges/RecentChangeFactory.php index dce50f1..8f1c5ee 100644 --- a/client/includes/RecentChanges/RecentChangeFactory.php +++ b/client/includes/RecentChanges/RecentChangeFactory.php @@ -180,12 +180,9 @@ $changesForComment = [ $change ]; - if ( $change->hasField( 'info' ) ) { - $info = $change->getField( 'info' ); - - if ( isset( $info['changes'] ) ) { - $changesForComment = $info['changes']; - } + $info = $change->getInfo(); + if ( isset( $info['changes'] ) ) { + $changesForComment = $info['changes']; } return $this->getEditCommentMulti( $changesForComment, $target ); diff --git a/lib/includes/Changes/ChangeRow.php b/lib/includes/Changes/ChangeRow.php index e917ad8..68d3b3f 100644 --- a/lib/includes/Changes/ChangeRow.php +++ b/lib/includes/Changes/ChangeRow.php @@ -112,7 +112,7 @@ * * @return array */ - protected function getInfo( $cache = 'no' ) { + public function getInfo( $cache = 'no' ) { $info = $this->hasField( 'info' ) ? $this->getField( 'info' ) : []; if ( $cache === 'cache' ) { diff --git a/lib/tests/phpunit/Changes/TestChanges.php b/lib/tests/phpunit/Changes/TestChanges.php index 96795d3..8f64cb5 100644 --- a/lib/tests/phpunit/Changes/TestChanges.php +++ b/lib/tests/phpunit/Changes/TestChanges.php @@ -205,13 +205,9 @@ /* @var ChangeRow $change */ foreach ( $changes as $change ) { - if ( $change->hasField( 'info' ) ) { - $info = $change->getField( 'info' ); - - $info = array_intersect_key( $info, $infoFilter ); - - $change->setField( 'info', $info ); - } + $info = $change->getInfo(); + $info = array_intersect_key( $info, $infoFilter ); + $change->setField( 'info', $info ); $filteredChanges[] = $change; } diff --git a/repo/includes/Store/Sql/SqlChangeStore.php b/repo/includes/Store/Sql/SqlChangeStore.php index ebbd745..e2c0448 100644 --- a/repo/includes/Store/Sql/SqlChangeStore.php +++ b/repo/includes/Store/Sql/SqlChangeStore.php @@ -83,7 +83,7 @@ $objectId = $change->hasField( 'object_id' ) ? $change->getObjectId() : ''; $revisionId = $change->hasField( 'revision_id' ) ? $change->getField( 'revision_id' ) : '0'; $userId = $change->hasField( 'user_id' ) ? $change->getField( 'user_id' ) : '0'; - $info = $change->getField( 'info' ); + $info = $change->getInfo(); return array( 'change_type' => $type, -- To view, visit https://gerrit.wikimedia.org/r/340109 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5d1ec960fc2870eb88a8b441c6500a56b3b37a4a Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits