Merge "Revert "Use display name in category page subheadings if provided""
[lhc/web/wiklou.git] / includes / api / ApiClearHasMsg.php
index 32e20e8..13b3577 100644 (file)
 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' );
        }
 
@@ -42,14 +48,11 @@ class ApiClearHasMsg extends ApiBase {
                return false;
        }
 
-       public function getDescription() {
-               return array( 'Clears the hasmsg flag for current user.' );
-       }
-
-       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() {