Amire80 has uploaded a new change for review.

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


Change subject: Move user page deletion code to the special page
......................................................................

Move user page deletion code to the special page

It is only used for tests, so it should be near the testing functions.

Change-Id: I72d6325fe11683b64916ff527fc8738961a28a0a
---
M specials/SpecialManageTranslatorSandbox.php
M utils/TranslateSandbox.php
2 files changed, 28 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Translate 
refs/changes/54/103554/1

diff --git a/specials/SpecialManageTranslatorSandbox.php 
b/specials/SpecialManageTranslatorSandbox.php
index 83eb934..8d6516f 100644
--- a/specials/SpecialManageTranslatorSandbox.php
+++ b/specials/SpecialManageTranslatorSandbox.php
@@ -38,6 +38,29 @@
        }
 
        /**
+        * Deletes a user page if it exists.
+        * This is needed especially when deleting sandbox users
+        * that were created as part of the integration tests.
+        * @since 2013.12
+        * @param User $user
+        */
+       protected function deleteUserPage( $user ) {
+               $userpage = WikiPage::factory( $user->getUserPage() );
+               if ( $userpage->exists() ) {
+                       $dummyError = '';
+                       $userpage->doDeleteArticleReal(
+                               wfMessage( 'tsb-delete-userpage-summary' 
)->inContentLanguage()->text(),
+                               false,
+                               0,
+                               true,
+                               $dummyError,
+                               $this->getUser()
+                       );
+               }
+
+       }
+
+       /**
         * Add users to the sandbox or delete them to facilitate browsers tests.
         * Use with caution!
         */
@@ -66,6 +89,7 @@
 
                                        // Get rid of users, even if promoted 
during tests
                                        $userToDelete = User::newFromName( 
$name, false );
+                                       $this->deleteUserPage( $userToDelete );
                                        TranslateSandbox::deleteUser( 
$userToDelete, 'force' );
 
                                        $user = TranslateSandbox::addUser( 
$name, "$prefix$i...@pupun.kolo", 'porkkana' );
@@ -101,7 +125,10 @@
                        }
 
                        // Another account for testing a translator to multiple 
languages
-                       TranslateSandbox::deleteUser( User::newFromName( 
'Kissa', false ), 'force' );
+                       $oldPolyglotUser = User::newFromName( 'Kissa', false );
+                       $this->deleteUserPage( $oldPolyglotUser );
+                       TranslateSandbox::deleteUser( $oldPolyglotUser, 'force' 
);
+
                        $polyglotUser = TranslateSandbox::addUser( 'Kissa', 
'ki...@pupun.kolo', 'porkkana' );
                        $polyglotUser->setOption(
                                'translate-sandbox',
diff --git a/utils/TranslateSandbox.php b/utils/TranslateSandbox.php
index 5d7f098..2edff2c 100644
--- a/utils/TranslateSandbox.php
+++ b/utils/TranslateSandbox.php
@@ -54,16 +54,6 @@
                        throw new MWException( "Not a sandboxed user" );
                }
 
-               // Delete the user page.
-               // This is needed especially when deleting sandbox users
-               // that were created as part of the integration tests.
-               $userpage = WikiPage::factory( $user->getUserPage() );
-               if ( $userpage->exists() ) {
-                       $userpage->doDeleteArticleReal(
-                               wfMessage( 'tsb-delete-userpage-summary' 
)->inContentLanguage()->text()
-                       );
-               }
-
                // Delete from database
                $dbw = wfGetDB( DB_MASTER );
                $dbw->delete( 'user', array( 'user_id' => $uid ), __METHOD__ );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I72d6325fe11683b64916ff527fc8738961a28a0a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Translate
Gerrit-Branch: master
Gerrit-Owner: Amire80 <amir.ahar...@mail.huji.ac.il>

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

Reply via email to