Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/270893

Change subject: Validations should not fail the translation save
......................................................................

Validations should not fail the translation save

For example, if restbase is down it should not affect the saving of transations.
Followup: I3eb8ab4f3ab5ba7b2f2f302419facc1f42e33fdc

Change-Id: I1c8ad504fd49dd325a9da14c2c8a214cc8bd4477
---
M api/ApiContentTranslationSave.php
1 file changed, 11 insertions(+), 5 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/93/270893/1

diff --git a/api/ApiContentTranslationSave.php 
b/api/ApiContentTranslationSave.php
index 2df58a7..aeed910 100644
--- a/api/ApiContentTranslationSave.php
+++ b/api/ApiContentTranslationSave.php
@@ -84,11 +84,17 @@
                $checker = new AbuseFilterCheck();
                $restbaseClient = new RestbaseClient( $this->getConfig() );
                $sectionHTML = $translationUnit->getContent();
-
-               // The section content is HTML. AbuseFilter need wikitext.
-               $text = $restbaseClient->convertHtmlToWikitext( $title, 
$sectionHTML );
-
-               return $checker->checkSection( $this->getUser(), $title, $text 
);
+               $results = array();
+               // We need to catch any exceptions here - For example, if 
restbase is down
+               // it should not affect the saving of transations.
+               try {
+                       // The section content is HTML. AbuseFilter need 
wikitext.
+                       $text = $restbaseClient->convertHtmlToWikitext( $title, 
$sectionHTML );
+                       $results = $checker->checkSection( $this->getUser(), 
$title, $text );
+               } catch ( Exception $e ) {
+                       // Validation failed. But proceed.
+               }
+               return $results;
        }
 
        public function getAllowedParams() {

-- 
To view, visit https://gerrit.wikimedia.org/r/270893
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1c8ad504fd49dd325a9da14c2c8a214cc8bd4477
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

Reply via email to