Nikerabbit has uploaded a new change for review.

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

Change subject: Wrong url for pages when $wgContentTranslationTranslateInTarget 
= false
......................................................................

Wrong url for pages when $wgContentTranslationTranslateInTarget = false

The wrong url is stored in the database. This only fixes it for pages published
after this fix is applied.

Bug: T86320
Change-Id: I3e4ced92089e8b5b0b65b5d1eb81abdf4eab228e
---
M api/ApiContentTranslationPublish.php
1 file changed, 17 insertions(+), 8 deletions(-)


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

diff --git a/api/ApiContentTranslationPublish.php 
b/api/ApiContentTranslationPublish.php
index c411be4..566baf4 100644
--- a/api/ApiContentTranslationPublish.php
+++ b/api/ApiContentTranslationPublish.php
@@ -193,7 +193,7 @@
        }
 
        public function saveTranslationHistory( $params ) {
-               global $wgContentTranslationDatabase;
+               global $wgContentTranslationDatabase, 
$wgContentTranslationTranslateInTarget;
 
                if ( $wgContentTranslationDatabase === null ) {
                        // Central CX database not configured.
@@ -201,10 +201,21 @@
                }
                $user = $this->getUser();
                $translator = new ContentTranslation\Translator( $user );
-               $targetTitle = ContentTranslation\SiteMapper::getTargetTitle(
-                       $params['title'],
-                       $this->getUser()->getName()
-               );
+
+               if ( $wgContentTranslationTranslateInTarget ) {
+                       $targetTitle = Title::newFromText( $params['title'] );
+                       if ( !$targetTitle ) {
+                               throw new InvalidArgumentException( "Invalid 
target title given" );
+                       }
+                       $targetURL = $targetTitle->getCanonicalUrl();
+               } else {
+                       $targetTitle = 
ContentTranslation\SiteMapper::getTargetTitle(
+                               $params['title'],
+                               $this->getUser()->getName()
+                       );
+                       $targetURL = ContentTranslation\SiteMapper::getPageURL( 
$params['to'], $targetTitle );
+               }
+
                $translation = new ContentTranslation\Translation( array(
                        'sourceTitle' => $params['sourcetitle'],
                        'targetTitle' => $params['title'],
@@ -213,9 +224,7 @@
                        'sourceURL' => 
ContentTranslation\SiteMapper::getPageURL(
                                $params['from'], $params['sourcetitle']
                        ),
-                       'targetURL' => 
ContentTranslation\SiteMapper::getPageURL(
-                               $params['to'], $targetTitle
-                       ),
+                       'targetURL' => $targetURL,
                        'status' => $params['status'],
                        'progress' => $params['progress'],
                        // XXX Do not overwrite startedTranslator when we have 
"draft save" feature.

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3e4ced92089e8b5b0b65b5d1eb81abdf4eab228e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Nikerabbit <niklas.laxst...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to