jenkins-bot has submitted this change and it was merged.
Change subject: Assume users with the same name on the repo and client are the
same
......................................................................
Assume users with the same name on the repo and client are the same
This way we are be able to remove the binding against CentralAuth,
now that the SULF has been finished. The collateral damage caused
by this should be very low to non-existant, given that virtually
no one except for the Wikimedia foundation uses CentralAuth…
and those that do probably don't have Wikibase installed.
Also needed in order to be able to write tests for
UpdateRepoHookHandlers without having to work with CentralAuth.
In case this behaviour is not desirable, UpdateRepo can be disabled
completely by setting the "propagateChangesToRepo" client setting
to false.
Change-Id: I2f9c0c5743a66b1e62f633ee3c64dad407fef424
---
M client/includes/Hooks/UpdateRepoHookHandlers.php
M client/includes/UpdateRepo/UpdateRepo.php
M client/includes/UpdateRepo/UpdateRepoOnMove.php
M client/tests/phpunit/includes/UpdateRepo/UpdateRepoOnDeleteTest.php
M client/tests/phpunit/includes/UpdateRepo/UpdateRepoOnMoveTest.php
M repo/includes/UpdateRepo/UpdateRepoJob.php
6 files changed, 13 insertions(+), 79 deletions(-)
Approvals:
Adrian Heine: Looks good to me, approved
Daniel Kinzler: Looks good to me, but someone else must approve
Thiemo Mättig (WMDE): Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/client/includes/Hooks/UpdateRepoHookHandlers.php
b/client/includes/Hooks/UpdateRepoHookHandlers.php
index 9f5afb7..21bec73 100644
--- a/client/includes/Hooks/UpdateRepoHookHandlers.php
+++ b/client/includes/Hooks/UpdateRepoHookHandlers.php
@@ -8,7 +8,6 @@
use MWException;
use Title;
use User;
-use Wikibase\Client\UpdateRepo\UpdateRepo;
use Wikibase\Client\UpdateRepo\UpdateRepoOnDelete;
use Wikibase\Client\UpdateRepo\UpdateRepoOnMove;
use Wikibase\Client\WikibaseClient;
@@ -88,8 +87,8 @@
}
/**
- * After a page has been moved also update the item on the repo
- * This only works with CentralAuth
+ * After a page has been moved also update the item on the repo.
+ * This only works if there's a user account with the same name on the
repo.
*
* @see https://www.mediawiki.org/wiki/Manual:Hooks/TitleMoveComplete
*
@@ -120,8 +119,8 @@
}
/**
- * After a page has been deleted also update the item on the repo
- * This only works with CentralAuth
+ * After a page has been deleted also update the item on the repo.
+ * This only works if there's a user account with the same name on the
repo.
*
* @see
https://www.mediawiki.org/wiki/Manual:Hooks/ArticleDeleteComplete
*
@@ -184,16 +183,6 @@
}
/**
- * Whether a given UpdateRepo should be pushed to the repo
- *
- * @param UpdateRepo $updateRepo
- * @return bool
- */
- private function shouldBePushed( UpdateRepo $updateRepo ) {
- return $updateRepo->getEntityId() &&
$updateRepo->userIsValidOnRepo();
- }
-
- /**
* @param Title $title
* @param User $user
*
@@ -212,7 +201,7 @@
$title
);
- if ( !$this->shouldBePushed( $updateRepo ) ) {
+ if ( !$updateRepo->getEntityId() ) {
return true;
}
@@ -257,7 +246,7 @@
$newTitle
);
- if ( !$this->shouldBePushed( $updateRepo ) ) {
+ if ( !$updateRepo->getEntityId() ) {
return true;
}
diff --git a/client/includes/UpdateRepo/UpdateRepo.php
b/client/includes/UpdateRepo/UpdateRepo.php
index 8c92cd9..78f30fe 100644
--- a/client/includes/UpdateRepo/UpdateRepo.php
+++ b/client/includes/UpdateRepo/UpdateRepo.php
@@ -2,7 +2,6 @@
namespace Wikibase\Client\UpdateRepo;
-use CentralAuthUser;
use IJobSpecification;
use JobQueueGroup;
use JobSpecification;
@@ -101,49 +100,6 @@
}
return $this->entityId;
- }
-
- /**
- * Find out whether the user also exists on the repo and belongs to the
- * same global account (uses CentralAuth).
- *
- * @return bool
- */
- public function userIsValidOnRepo() {
- if ( !class_exists( CentralAuthUser::class ) ) {
- // We can't do anything without CentralAuth as there's
no way to verify that
- // the local user equals the repo one with the same name
- wfDebugLog(
- 'UpdateRepo',
- "Can't validate user " . $this->user->getName()
. ": class CentralAuthUser doesn't exist"
- );
-
- return false;
- }
-
- $caUser = CentralAuthUser::getInstance( $this->user );
- if ( !$caUser || !$caUser->exists() ) {
- // The current user doesn't have a central account
- wfDebugLog(
- 'UpdateRepo',
- "Can't validate user " . $this->user->getName()
. ": User doesn't have a global account"
- );
-
- return false;
- }
-
- if ( !$caUser->isAttached() || !$caUser->attachedOn(
$this->repoDB ) ) {
- // Either the user account on this wiki or the one on
the repo do not exist
- // or they aren't connected
- wfDebugLog(
- 'UpdateRepo',
- "Can't validate user " . $this->user->getName()
. ": User is not attached locally or on {$this->repoDB}"
- );
-
- return false;
- }
-
- return true;
}
/**
diff --git a/client/includes/UpdateRepo/UpdateRepoOnMove.php
b/client/includes/UpdateRepo/UpdateRepoOnMove.php
index 78291dc..26f7964 100644
--- a/client/includes/UpdateRepo/UpdateRepoOnMove.php
+++ b/client/includes/UpdateRepo/UpdateRepoOnMove.php
@@ -32,7 +32,8 @@
public function __construct(
$repoDB,
SiteLinkLookup $siteLinkLookup,
- User $user, $siteId,
+ User $user,
+ $siteId,
Title $oldTitle,
Title $newTitle
) {
diff --git
a/client/tests/phpunit/includes/UpdateRepo/UpdateRepoOnDeleteTest.php
b/client/tests/phpunit/includes/UpdateRepo/UpdateRepoOnDeleteTest.php
index c8b15c3..2ca54df 100644
--- a/client/tests/phpunit/includes/UpdateRepo/UpdateRepoOnDeleteTest.php
+++ b/client/tests/phpunit/includes/UpdateRepo/UpdateRepoOnDeleteTest.php
@@ -6,6 +6,7 @@
use JobQueueGroup;
use JobQueueRedis;
use JobSpecification;
+use PHPUnit_Framework_TestCase;
use Title;
use User;
use Wikibase\Client\UpdateRepo\UpdateRepoOnDelete;
@@ -23,7 +24,7 @@
* @license GPL-2.0+
* @author Marius Hoch < [email protected] >
*/
-class UpdateRepoOnDeleteTest extends \PHPUnit_Framework_TestCase {
+class UpdateRepoOnDeleteTest extends PHPUnit_Framework_TestCase {
/**
* Return some fake data for testing
@@ -101,12 +102,6 @@
->will( $this->returnValue( $jobQueue ) );
return $jobQueueGroupMock;
- }
-
- public function testUserIsValidOnRepo() {
- $updateRepo = $this->getNewUpdateRepoOnDelete();
-
- $this->assertFalse( $updateRepo->userIsValidOnRepo() );
}
/**
diff --git a/client/tests/phpunit/includes/UpdateRepo/UpdateRepoOnMoveTest.php
b/client/tests/phpunit/includes/UpdateRepo/UpdateRepoOnMoveTest.php
index 7cb7043..15bcd0b 100644
--- a/client/tests/phpunit/includes/UpdateRepo/UpdateRepoOnMoveTest.php
+++ b/client/tests/phpunit/includes/UpdateRepo/UpdateRepoOnMoveTest.php
@@ -6,6 +6,7 @@
use JobQueueGroup;
use JobQueueRedis;
use JobSpecification;
+use PHPUnit_Framework_TestCase;
use Title;
use User;
use Wikibase\Client\UpdateRepo\UpdateRepoOnMove;
@@ -23,7 +24,7 @@
* @license GPL-2.0+
* @author Marius Hoch < [email protected] >
*/
-class UpdateRepoOnMoveTest extends \PHPUnit_Framework_TestCase {
+class UpdateRepoOnMoveTest extends PHPUnit_Framework_TestCase {
/**
* Return some fake data for testing
@@ -109,12 +110,6 @@
->will( $this->returnValue( $jobQueue ) );
return $jobQueueGroupMock;
- }
-
- public function testUserIsValidOnRepo() {
- $updateRepo = $this->getNewUpdateRepoOnMove();
-
- $this->assertFalse( $updateRepo->userIsValidOnRepo() );
}
/**
diff --git a/repo/includes/UpdateRepo/UpdateRepoJob.php
b/repo/includes/UpdateRepo/UpdateRepoJob.php
index 3932a49..4b1255a 100644
--- a/repo/includes/UpdateRepo/UpdateRepoJob.php
+++ b/repo/includes/UpdateRepo/UpdateRepoJob.php
@@ -180,9 +180,7 @@
private function getUser( $name ) {
$user = User::newFromName( $name );
if ( !$user || !$user->isLoggedIn() ) {
- // This should never happen as we check with CentralAuth
- // that the user actually does exist
- wfLogWarning( "User $name doesn't exist while
CentralAuth pretends it does" );
+ wfDebugLog( 'UpdateRepo', "User $name doesn't exist." );
return false;
}
--
To view, visit https://gerrit.wikimedia.org/r/270255
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I2f9c0c5743a66b1e62f633ee3c64dad407fef424
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Hoo man <[email protected]>
Gerrit-Reviewer: Adrian Heine <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: JanZerebecki <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits