Merge "Add meta=userinfo&uiprop=latestcontrib"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 4 Apr 2019 23:23:54 +0000 (23:23 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 4 Apr 2019 23:23:54 +0000 (23:23 +0000)
1  2 
RELEASE-NOTES-1.33
includes/api/ApiQueryUserInfo.php

diff --combined RELEASE-NOTES-1.33
@@@ -84,8 -84,6 +84,8 @@@ For notes on 1.32.x and older releases
    is no longer a problem, because the code now ensures the timestamp is always
    higher than the previous one. The writes are guarded with CAS logic (check
    and set), which prevents updates that would overlap.
 +* $wgDBmysql5 (T196185) - This experimental setting, deprecated in 1.31, has
 +  been removed.
  
  === New user-facing features in 1.33 ===
  * (T96041) __EXPECTUNUSEDCATEGORY__ on a category page causes the category
    Content::getNativeData() for text-based content models.
  * (T214706) LinksUpdate::getAddedExternalLinks() and
    LinksUpdate::getRemovedExternalLinks() were introduced.
 +* (T213893) Added 'MaintenanceUpdateAddParams' hook
 +* (T219655) The MarkPatrolled hook has a new parameter for the tags
 +  associated with this entry in the patrol log.
  
  === External library changes in 1.33 ===
  ==== New external libraries ====
  * Added jakub-onderka/php-console-highlighter 0.3.2 explicitly (dev-only).
  
  ==== Changed external libraries ====
 -* Updated OOUI from v0.29.2 to v0.31.1.
 +* Updated OOUI from v0.29.2 to v0.31.2.
  * Updated OOjs Router from pre-release to v0.2.0.
  * Updated moment from v2.19.3 to v2.24.0.
  * Updated wikimedia/xmp-reader from 0.6.0 to 0.6.2.
  * Updated wikimedia/php-session-serializer from 1.0.6 to 1.0.7.
  
  ==== Removed external libraries ====
 -* 
 +* (T219403) jquery.ui.spinner, deprecated since 1.31, was removed.
  
  === Bug fixes in 1.33 ===
  * (T164211) Special:UserRights could sometimes fail with a
    if entirewatchlist is set, so updates may not be visible immediately
  * Block info will be added to "blocked" errors from more modules.
  * (T216245) Autoblocks will now be spread by action=edit and action=move.
+ * action=query&meta=userinfo has a new uiprop, 'latestcontrib', that returns
+   the date of user's latest contribution.
  
  === Action API internal changes in 1.33 ===
  * A number of deprecated methods for API documentation, intended for overriding
@@@ -344,13 -341,6 +346,13 @@@ because of Phabricator reports
    Use CdnCacheUpdate::newFromTitles() instead.
  * Handling of multiple arguments by the Block constructor, deprecated in 1.26,
    has been removed.
 +* The translation of main page in Sardinian (sc) was changed from "Pàgina Base"
 +  to "Pàgina printzipale". Existing wikis using this content language need to
 +  move the main page or change the name through MediaWiki:Mainpage page.
 +* wfSplitWikiID(), deprecated in 1.32, has been removed.
 +* MessageBlobStore::getBlob(), deprecated in 1.27, has been removed.
 +  Use ::getBlobs() instead.
 +* The .background-size() LESS mixin, deprecated in 1.27, has been removed.
  
  === Deprecations in 1.33 ===
  * The configuration option $wgUseESI has been deprecated, and is expected
    deprecated and will be removed in the future.
  * The FileBasedSiteLookup class has been deprecated. For a cacheable SiteLookup
    implementation, use CachingSiteStore instead.
 +* Language::viewPrevNext function is deprecated, use
 +  SpecialPage::buildPrevNextNavigation instead
  * ManualLogEntry::setTags() is deprecated, use ManualLogEntry::addTags()
    instead. The setTags() method was overriding the tags, addTags() doesn't
    override, only adds new tags.
 +* Block::isValid is deprecated, since it is no longer needed in core.
 +* Calling Maintenance::hasArg() as well as Maintenance::getArg() with no
 +  parameter has been deprecated. Please pass the argument number 0.
  
  === Other changes in 1.33 ===
  * (T201747) Html::openElement() warns if given an element name with a space
    changed to explicitly cast. Subclasses relying on the base-class
    implementation should check whether they need to override it now.
  * BagOStuff::add is now abstract and must explicitly be defined in subclasses.
 +* LinksDeletionUpdate is now a subclass of LinksUpdate. As a consequence,
 +  the following hooks will now be triggered upon page deletion in addition
 +  to page updates: LinksUpdateConstructed, LinksUpdate, LinksUpdateComplete.
 +  LinksUpdateAfterInsert is not triggered since deletions do not cause
 +  insertions into links tables.
 +* Category::newFromID( $id )->getID() will now return $id without any
 +  validation, to avoid a mostly unnecessary DB query.
  
  == Compatibility ==
  MediaWiki 1.33 requires PHP 7.0.13 or later. Although HHVM 3.18.5 or later is
@@@ -67,8 -67,8 +67,8 @@@ class ApiQueryUserInfo extends ApiQuery
                $vals['blockid'] = $block->getId();
                $vals['blockedby'] = $block->getByName();
                $vals['blockedbyid'] = $block->getBy();
 -              $vals['blockreason'] = $block->mReason;
 -              $vals['blockedtimestamp'] = wfTimestamp( TS_ISO_8601, $block->mTimestamp );
 +              $vals['blockreason'] = $block->getReason();
 +              $vals['blockedtimestamp'] = wfTimestamp( TS_ISO_8601, $block->getTimestamp() );
                $vals['blockexpiry'] = ApiResult::formatExpiry( $block->getExpiry(), 'infinite' );
                $vals['blockpartial'] = !$block->isSitewide();
                if ( $block->getSystemBlockType() !== null ) {
                        $vals['realname'] = $user->getRealName();
                }
  
 -              if ( $user->isAllowed( 'viewmyprivateinfo' ) ) {
 -                      if ( isset( $this->prop['email'] ) ) {
 -                              $vals['email'] = $user->getEmail();
 -                              $auth = $user->getEmailAuthenticationTimestamp();
 -                              if ( !is_null( $auth ) ) {
 -                                      $vals['emailauthenticated'] = wfTimestamp( TS_ISO_8601, $auth );
 -                              }
 +              if ( $user->isAllowed( 'viewmyprivateinfo' ) && isset( $this->prop['email'] ) ) {
 +                      $vals['email'] = $user->getEmail();
 +                      $auth = $user->getEmailAuthenticationTimestamp();
 +                      if ( $auth !== null ) {
 +                              $vals['emailauthenticated'] = wfTimestamp( TS_ISO_8601, $auth );
                        }
                }
  
                        );
                }
  
+               if ( isset( $this->prop['latestcontrib'] ) ) {
+                       $ts = $this->getLatestContributionTime();
+                       if ( $ts !== null ) {
+                               $vals['latestcontrib'] = $ts;
+                       }
+               }
                return $vals;
        }
  
                return $retval;
        }
  
+       /**
+        * @return string|null ISO 8601 timestamp of current user's last contribution or null if none
+        */
+       protected function getLatestContributionTime() {
+               global $wgActorTableSchemaMigrationStage;
+               $user = $this->getUser();
+               $dbr = $this->getDB();
+               if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_READ_NEW ) {
+                       if ( $user->getActorId() === null ) {
+                               return null;
+                       }
+                       $res = $dbr->selectField( 'revision_actor_temp',
+                               'MAX(revactor_timestamp)',
+                               [ 'revactor_actor' => $user->getActorId() ],
+                               __METHOD__
+                       );
+               } else {
+                       if ( $user->isLoggedIn() ) {
+                               $conds = [ 'rev_user' => $user->getId() ];
+                       } else {
+                               $conds = [ 'rev_user_text' => $user->getName() ];
+                       }
+                       $res = $dbr->selectField( 'revision',
+                               'MAX(rev_timestamp)',
+                               $conds,
+                               __METHOD__
+                       );
+               }
+               return $res ? wfTimestamp( TS_ISO_8601, $res ) : null;
+       }
        public function getAllowedParams() {
                return [
                        'prop' => [
                                        'unreadcount',
                                        'centralids',
                                        'preferencestoken',
+                                       'latestcontrib',
                                ],
                                ApiBase::PARAM_HELP_MSG_PER_VALUE => [
                                        'unreadcount' => [