Santhosh has uploaded a new change for review. https://gerrit.wikimedia.org/r/269598
Change subject: Fresh translation after deletion should have correct author and dates ...................................................................... Fresh translation after deletion should have correct author and dates The started-by and started-date fields for this translation were not updated in these cases. Bug: T125959 Change-Id: I91658e6720e1dddf94ac5caa7da406d091a2ee48 --- M includes/Translation.php 1 file changed, 14 insertions(+), 5 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation refs/changes/98/269598/1 diff --git a/includes/Translation.php b/includes/Translation.php index 66db0cc..a4cb45e 100644 --- a/includes/Translation.php +++ b/includes/Translation.php @@ -42,14 +42,11 @@ $this->translation['id'] = (int)$dbw->insertId(); } - public function update() { + public function update( $freshTranslation = false ) { $dbw = Database::getConnection( DB_MASTER ); $values = array( - 'translation_source_title' => $this->translation['sourceTitle'], 'translation_target_title' => $this->translation['targetTitle'], - 'translation_source_language' => $this->translation['sourceLanguage'], - 'translation_target_language' => $this->translation['targetLanguage'], 'translation_source_revision_id' => $this->translation['sourceRevisionId'], 'translation_source_url' => $this->translation['sourceURL'], 'translation_status' => $this->translation['status'], @@ -63,6 +60,11 @@ $values['translation_target_revision_id'] = $this->translation['targetRevisionId']; } + if ( $freshTranslation === true ) { + $values['translation_start_timestamp'] = $dbw->timestamp(); + $values['translation_started_by'] = $this->translation['startedTranslator']; + } + $dbw->update( 'cx_translations', $values, @@ -72,6 +74,8 @@ } public function save() { + $freshTranslation = false; + $existingTranslation = Translation::find( $this->translation['sourceLanguage'], $this->translation['targetLanguage'], @@ -81,8 +85,13 @@ if ( $existingTranslation === null ) { $this->create(); } else { + if ( $existingTranslation->translation['status'] === 'deleted' ) { + // Existing translation is deleted, so this is a fresh start of same + // language pair and source title. + $freshTranslation = true; + } $this->translation['id'] = $existingTranslation->getTranslationId(); - $this->update(); + $this->update( $freshTranslation ); } } -- To view, visit https://gerrit.wikimedia.org/r/269598 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I91658e6720e1dddf94ac5caa7da406d091a2ee48 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/ContentTranslation Gerrit-Branch: master Gerrit-Owner: Santhosh <santhosh.thottin...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits