https://bugzilla.wikimedia.org/show_bug.cgi?id=45967

       Web browser: ---
            Bug ID: 45967
           Summary: User.php please implement User::deleteOption(
                    $optionKey )
           Product: MediaWiki
           Version: 1.21-git
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: Unprioritized
         Component: User preferences
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    Classification: Unclassified
   Mobile Platform: ---

tl;dr
in core please implement User::deleteOption( $key )
delete from user_property where (up_user=User) and (up_property=$key)


In my extension (OpenID) I need a method to delete all keys of $wgUser where
they have key 'openid_trust'.

We already have User::setOption( $key, $value ) and User::resetOptions( $kind
); 
BUT: resetOptions is apparently not what I need, it is intended for something
different (reset options to default values).

I suggest that a core developer adds a method for *deletion* of *any* entries
$key of a user $user, i.e. something like

delete from user_property where (up_user=$user) and (up_property=$key)


Long version
============

I am unsure whether

$wgUser->resetOptions( 'openid_trust' ); // definition in includes/User.php

is intended to delete such a user_properties 'openid_trust',



When reading the documentation I feel, that resetOptions() is designed to
delete properties of a certain kind, but not hook-definied properties like
'openid_trust'.

My current understanding is, that User:setOption() and User:resetOptions() are
designed differently, and resetOptions is not the complementary action.

Therefore I suggest that a new function in core User:deleteOption( $key ) is
necessary, which deletes all keys $key for User.



if ( $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal(
'wpEditToken' ), $trustedSiteToBeDeleted ) ) {
if ( $trustedSiteToBeDeleted === "*" ) {
// $this->SetUserTrustArray( $wgUser, array() );
// remove all trusted sites of that user

// DOES NOT WORK
$wgUser->resetOptions( 'openid_trust' );
// DOES NOT WORK

$wgUser->saveSettings();
$wgOut->addWikiMsg( 'openid-trusted-sites-delete-all-confirmation-success-text'
);
} else {
$this->SetUserTrust( $wgUser, $trustedSiteToBeDeleted, NULL );
$wgUser->saveSettings();
$wgOut->addWikiMsg( 'openid-trusted-sites-delete-confirmation-success-text',
$trustedSiteToBeDeleted );

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.
You are watching all bug changes.
_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to