Remove Revision::getRevisionText from ApiQueryDeletedrevs
[lhc/web/wiklou.git] / includes / api / ApiFeedWatchlist.php
index c21ac12..953c4d8 100644 (file)
@@ -20,6 +20,8 @@
  * @file
  */
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * This action allows users to get their watchlist items in RSS/Atom formats.
  * When executed, it performs a nested call to the API to get the needed data,
@@ -61,7 +63,7 @@ class ApiFeedWatchlist extends ApiBase {
                        }
 
                        // limit to the number of hours going from now back
-                       $endTime = wfTimestamp( TS_MW, time() - intval( $params['hours'] * 60 * 60 ) );
+                       $endTime = wfTimestamp( TS_MW, time() - (int)$params['hours'] * 60 * 60 );
 
                        // Prepare parameters for nested request
                        $fauxReqArr = [
@@ -69,7 +71,7 @@ class ApiFeedWatchlist extends ApiBase {
                                'meta' => 'siteinfo',
                                'siprop' => 'general',
                                'list' => 'watchlist',
-                               'wlprop' => 'title|user|comment|timestamp|ids',
+                               'wlprop' => 'title|user|comment|timestamp|ids|loginfo',
                                'wldir' => 'older', // reverse order - from newest to oldest
                                'wlend' => $endTime, // stop at this time
                                'wllimit' => min( 50, $this->getConfig()->get( 'FeedLimit' ) )
@@ -102,10 +104,8 @@ class ApiFeedWatchlist extends ApiBase {
                                $fauxReqArr['wlallrev'] = '';
                        }
 
-                       // Create the request
                        $fauxReq = new FauxRequest( $fauxReqArr );
 
-                       // Execute
                        $module = new ApiMain( $fauxReq );
                        $module->execute();
 
@@ -150,6 +150,7 @@ class ApiFeedWatchlist extends ApiBase {
 
                        if ( $e instanceof ApiUsageException ) {
                                foreach ( $e->getStatusValue()->getErrors() as $error ) {
+                                       // @phan-suppress-next-line PhanUndeclaredMethod
                                        $msg = ApiMessage::create( $error )
                                                ->inLanguage( $this->getLanguage() );
                                        $errorTitle = $this->msg( 'api-feed-error-title', $msg->getApiCode() );
@@ -157,12 +158,8 @@ class ApiFeedWatchlist extends ApiBase {
                                        $feedItems[] = new FeedItem( $errorTitle, $errorText, '', '', '' );
                                }
                        } else {
-                               if ( $e instanceof UsageException ) {
-                                       $errorCode = $e->getCodeString();
-                               } else {
-                                       // Something is seriously wrong
-                                       $errorCode = 'internal_api_error';
-                               }
+                               // Something is seriously wrong
+                               $errorCode = 'internal_api_error';
                                $errorTitle = $this->msg( 'api-feed-error-title', $errorCode );
                                $errorText = $e->getMessage();
                                $feedItems[] = new FeedItem( $errorTitle, $errorText, '', '', '' );
@@ -197,7 +194,12 @@ class ApiFeedWatchlist extends ApiBase {
                        }
                }
                if ( isset( $info['revid'] ) ) {
-                       $titleUrl = $title->getFullURL( [ 'diff' => $info['revid'] ] );
+                       if ( $info['revid'] === 0 && isset( $info['logid'] ) ) {
+                               $logTitle = Title::makeTitle( NS_SPECIAL, 'Log' );
+                               $titleUrl = $logTitle->getFullURL( [ 'logid' => $info['logid'] ] );
+                       } else {
+                               $titleUrl = $title->getFullURL( [ 'diff' => $info['revid'] ] );
+                       }
                } else {
                        $titleUrl = $title->getFullURL( $curidParam );
                }
@@ -210,8 +212,8 @@ class ApiFeedWatchlist extends ApiBase {
                if ( $this->linkToSections && $comment !== null &&
                        preg_match( '!(.*)/\*\s*(.*?)\s*\*/(.*)!', $comment, $matches )
                ) {
-                       global $wgParser;
-                       $titleUrl .= $wgParser->guessSectionNameFromWikiText( $matches[ 2 ] );
+                       $titleUrl .= MediaWikiServices::getInstance()->getParser()
+                               ->guessSectionNameFromWikiText( $matches[ 2 ] );
                }
 
                $timestamp = $info['timestamp'];