jenkins-bot has submitted this change and it was merged.

Change subject: Translation stash storage: separate columns for namespace and 
title
......................................................................


Translation stash storage: separate columns for namespace and title

Avoids a size limit error of ts_key column. Tests were updated.

If you already have this table created, you must drop it before
running update.php.

Change-Id: If950d1de558cb69d4ddba340ab0f506a98325d4f
---
M sql/translate_stash.sql
M stash/TranslationStashStorage.php
M tests/TranslationStashStorageTest.php
3 files changed, 10 insertions(+), 9 deletions(-)

Approvals:
  Nikerabbit: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/sql/translate_stash.sql b/sql/translate_stash.sql
index e7de529..b0a651f 100644
--- a/sql/translate_stash.sql
+++ b/sql/translate_stash.sql
@@ -1,10 +1,10 @@
 -- Translate translation stash
 CREATE TABLE /*$wgDBprefix*/translate_stash (
   ts_user int NOT NULL,
-  -- 255 bytes for title and some slack for namespace prefix
-  ts_key varchar(300) binary NOT NULL,
+  ts_namespace int(11) NOT NULL,
+  ts_title varchar(255) binary NOT NULL,
   ts_value mediumblob NOT NULL,
   ts_metadata mediumblob NOT NULL,
 
-  PRIMARY KEY (ts_user, ts_key)
+  PRIMARY KEY (ts_user, ts_namespace, ts_title)
 ) /*$wgDBTableOptions*/;
diff --git a/stash/TranslationStashStorage.php 
b/stash/TranslationStashStorage.php
index 8b1acb5..8f5865b 100644
--- a/stash/TranslationStashStorage.php
+++ b/stash/TranslationStashStorage.php
@@ -27,13 +27,14 @@
        public function addTranslation( StashedTranslation $item ) {
                $row = array(
                        'ts_user' => $item->getUser()->getId(),
-                       'ts_key' => $item->getTitle()->getDBKey(),
+                       'ts_title' => $item->getTitle()->getDBKey(),
+                       'ts_namespace' => $item->getTitle()->getNamespace(),
                        'ts_value' => $item->getValue(),
                        'ts_metadata' => serialize( $item->getMetadata() ),
                );
 
                $indexes = array(
-                       array( 'ts_user', 'ts_key' )
+                       array( 'ts_user', 'ts_namespace', 'ts_title'  )
                );
 
                $this->db->replace( $this->dbTable, $indexes, $row, __METHOD__ 
);
@@ -47,7 +48,7 @@
         */
        public function getTranslations( User $user ) {
                $conds = array( 'ts_user' => $user->getId() );
-               $fields = array( 'ts_key', 'ts_value', 'ts_metadata' );
+               $fields = array( 'ts_namespace', 'ts_title', 'ts_value', 
'ts_metadata' );
 
                $res = $this->db->select( $this->dbTable, $fields, $conds, 
__METHOD__ );
 
@@ -55,7 +56,7 @@
                foreach ( $res as $row ) {
                        $objects[] = new StashedTranslation(
                                $user,
-                               Title::newFromText( $row->ts_key ),
+                               Title::makeTitle( $row->ts_namespace, 
$row->ts_title ),
                                $row->ts_value,
                                unserialize( $row->ts_metadata )
                        );
diff --git a/tests/TranslationStashStorageTest.php 
b/tests/TranslationStashStorageTest.php
index 346af94..b1f4cc8 100644
--- a/tests/TranslationStashStorageTest.php
+++ b/tests/TranslationStashStorageTest.php
@@ -15,14 +15,14 @@
 
                $translation1 = new StashedTranslation(
                        User::newFromId( 1 ),
-                       Title::newFromText( __METHOD__ ),
+                       Title::makeTitle( NS_MAIN, __METHOD__ ),
                        'test value',
                        array( 'kissa', 'kala' )
                );
 
                $translation2 = new StashedTranslation(
                        User::newFromId( 2 ),
-                       Title::newFromText( __METHOD__ ),
+                       Title::makeTitle( NS_MAIN, __METHOD__ ),
                        'test value 2',
                        array( 'kissa', 'kala' )
                );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: If950d1de558cb69d4ddba340ab0f506a98325d4f
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/Translate
Gerrit-Branch: master
Gerrit-Owner: Santhosh <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to