Santhosh has uploaded a new change for review.
https://gerrit.wikimedia.org/r/278845
Change subject: While deleting unplished translation, delete the items from
cx_corpora
......................................................................
While deleting unplished translation, delete the items from cx_corpora
If we are not deleting them, the translation units associated with the
translaiton id will get restored if the translator decide to translate
the same source article.
Testplan:
1. Translate an article. Translate some sections. Do not publish.
2. Go back to dashboard and delete the translation
3. Start a translation for same source title and language pair
4. Translate just one section, save, resume.
5. Without this patch, you will see the sections saved in #1 also
get restored. With this patch, you wont see the sections you
did not translate in second attempt get restored.
Bug: T128162
Change-Id: I52095d58397d35b199fb9c0f971ffddb49a71c87
---
M api/ApiContentTranslationDelete.php
M includes/TranslationStorageManager.php
2 files changed, 27 insertions(+), 5 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation
refs/changes/45/278845/1
diff --git a/api/ApiContentTranslationDelete.php
b/api/ApiContentTranslationDelete.php
index dcbe0b2..f34d604 100644
--- a/api/ApiContentTranslationDelete.php
+++ b/api/ApiContentTranslationDelete.php
@@ -6,6 +6,12 @@
* @copyright See AUTHORS.txt
* @license GPL-2.0+
*/
+
+use ContentTranslation\TranslationStorageManager;
+use ContentTranslation\Translator;
+use ContentTranslation\Translation;
+use ContentTranslation\Draft;
+
class ApiContentTranslationDelete extends ApiBase {
public function execute() {
@@ -16,8 +22,8 @@
$this->dieUsageMsg( 'blockedtext' );
}
- $translator = new ContentTranslation\Translator( $user );
- $translation = ContentTranslation\Translation::find(
+ $translator = new Translator( $user );
+ $translation = Translation::find(
$params['from'],
$params['to'],
$params['sourcetitle']
@@ -36,9 +42,10 @@
$translation->translation['status'] = 'published';
$translation->update();
} else {
- ContentTranslation\Translator::removeTranslation(
$translationId );
- ContentTranslation\Translation::delete( $translationId
);
- ContentTranslation\Draft::delete( $translationId );
+ Translator::removeTranslation( $translationId );
+ Translation::delete( $translationId );
+ Draft::delete( $translationId );
+ TranslationStorageManager::deleteTranslationUnits(
$translationId );
}
$result = array(
'result' => 'success'
diff --git a/includes/TranslationStorageManager.php
b/includes/TranslationStorageManager.php
index 64e11a5..1719501 100644
--- a/includes/TranslationStorageManager.php
+++ b/includes/TranslationStorageManager.php
@@ -57,6 +57,21 @@
}
/**
+ * Delete translation units associated with the given translation
identifier.
+ *
+ * @param int $translationId
+ */
+ public static function deleteTranslationUnits( $translationId ) {
+ $dbw = Database::getConnection( DB_MASTER );
+
+ $conditions = array(
+ 'cxc_translation_id' => $translationId,
+ );
+
+ $dbw->delete( 'cx_corpora', $conditions, __METHOD__ );
+ }
+
+ /**
* Save the translation unit.
* If the record exist, update it, otherwise create.
*
--
To view, visit https://gerrit.wikimedia.org/r/278845
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I52095d58397d35b199fb9c0f971ffddb49a71c87
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits