jenkins-bot has submitted this change and it was merged.
Change subject: add and use updateExternalDBGroups function, fixes #49641
......................................................................
add and use updateExternalDBGroups function, fixes #49641
This enables plugins to add/remove groups in an external authentication
service when a group is added via the MediaWiki interface without relying
on the related Hooks. Relying on the Hook would mean that a plugin cannot
use User::addGroup or User::delGroup to add/remove groups comming FROM
the authentication service, as these functions would call the hook and
then redundantly add these groups to the auth-service again.
Change-Id: Ia04d5bb30831a89dfc66128e3c335bbe07f724b6
---
M includes/AuthPlugin.php
M includes/User.php
M includes/specials/SpecialUserrights.php
3 files changed, 23 insertions(+), 1 deletion(-)
Approvals:
Anomie: Looks good to me, but someone else must approve
Parent5446: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/AuthPlugin.php b/includes/AuthPlugin.php
index a465817..84cf3d5 100644
--- a/includes/AuthPlugin.php
+++ b/includes/AuthPlugin.php
@@ -213,6 +213,19 @@
}
/**
+ * Update user groups in the external authentication database.
+ * Return true if successful.
+ *
+ * @param $user User object.
+ * @param $addgroups Groups to add.
+ * @param $delgroups Groups to remove.
+ * @return Boolean
+ */
+ public function updateExternalDBGroups( $user, $addgroups, $delgroups =
array() ) {
+ return true;
+ }
+
+ /**
* Check to see if external accounts can be created.
* Return true if external accounts can be created.
* @return Boolean
diff --git a/includes/User.php b/includes/User.php
index bb61e80..c6f660d 100644
--- a/includes/User.php
+++ b/includes/User.php
@@ -1162,16 +1162,20 @@
* @see $wgAutopromoteOnce
*/
public function addAutopromoteOnceGroups( $event ) {
- global $wgAutopromoteOnceLogInRC;
+ global $wgAutopromoteOnceLogInRC, $wgAuth;
$toPromote = array();
if ( $this->getId() ) {
$toPromote = Autopromote::getAutopromoteOnceGroups(
$this, $event );
if ( count( $toPromote ) ) {
$oldGroups = $this->getGroups(); // previous
groups
+
foreach ( $toPromote as $group ) {
$this->addGroup( $group );
}
+ // update groups in external authentication
database
+ $wgAuth->updateExternalDBGroups( $this,
$toPromote );
+
$newGroups = array_merge( $oldGroups,
$toPromote ); // all groups
$logEntry = new ManualLogEntry( 'rights',
'autopromote' );
diff --git a/includes/specials/SpecialUserrights.php
b/includes/specials/SpecialUserrights.php
index e893455..77f2063 100644
--- a/includes/specials/SpecialUserrights.php
+++ b/includes/specials/SpecialUserrights.php
@@ -216,6 +216,8 @@
* @return Array: Tuple of added, then removed groups
*/
function doSaveUserGroups( $user, $add, $remove, $reason = '' ) {
+ global $wgAuth;
+
// Validate input set...
$isself = ( $user->getName() == $this->getUser()->getName() );
$groups = $user->getGroups();
@@ -251,6 +253,9 @@
// Ensure that caches are cleared
$user->invalidateCache();
+ // update groups in external authentication database
+ $wgAuth->updateExternalDBGroups( $user, $add, $remove );
+
wfDebug( 'oldGroups: ' . print_r( $oldGroups, true ) );
wfDebug( 'newGroups: ' . print_r( $newGroups, true ) );
wfRunHooks( 'UserRights', array( &$user, $add, $remove ) );
--
To view, visit https://gerrit.wikimedia.org/r/70040
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia04d5bb30831a89dfc66128e3c335bbe07f724b6
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Mati <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: CSteipp <[email protected]>
Gerrit-Reviewer: Mati <[email protected]>
Gerrit-Reviewer: Parent5446 <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits