class ApiClearHasMsg extends ApiBase {
public function execute() {
$user = $this->getUser();
- $user->setNewtalk( false );
+ if ( $this->getRequest()->wasPosted() ) {
+ $user->setNewtalk( false );
+ } else {
+ DeferredUpdates::addCallableUpdate( function () use ( $user ) {
+ $user->setNewtalk( false );
+ } );
+ }
$this->getResult()->addValue( null, $this->getModuleName(), 'success' );
}
}
public function mustBePosted() {
- return false;
- }
-
- public function getDescription() {
- return array( 'Clears the hasmsg flag for current user.' );
+ return true;
}
- public function getExamples() {
- return array(
- 'api.php?action=clearhasmsg' => 'Clears the hasmsg flag for current user',
- );
+ protected function getExamplesMessages() {
+ return [
+ 'action=clearhasmsg'
+ => 'apihelp-clearhasmsg-example-1',
+ ];
}
public function getHelpUrls() {