Merge "WLFilters: reword watchlist-details slightly"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 1 Sep 2017 22:14:18 +0000 (22:14 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 1 Sep 2017 22:14:19 +0000 (22:14 +0000)
20 files changed:
RELEASE-NOTES-1.30
includes/Block.php
includes/CommentStore.php
includes/EditPage.php
includes/Revision.php
includes/changes/RecentChange.php
includes/deferred/LinksUpdate.php
includes/externalstore/ExternalStoreDB.php
includes/import/WikiRevision.php
includes/jobqueue/JobQueueDB.php
includes/libs/rdbms/database/IDatabase.php
includes/logging/LogEntry.php
includes/logging/LogPage.php
includes/page/WikiPage.php
includes/site/DBSiteStore.php
includes/upload/UploadStash.php
includes/user/User.php
maintenance/fixExtLinksProtocolRelative.php
resources/src/mediawiki.special/mediawiki.special.changeslist.legend.js
tests/phpunit/includes/CommentStoreTest.php

index d38a34d..93d52b8 100644 (file)
@@ -189,6 +189,8 @@ changes to languages because of Phabricator reports.
 * MWMemcached and MemCachedClientforWiki classes (deprecated in 1.27) were removed.
   The MemcachedClient class should be used instead.
 * EditPage::isOouiEnabled() is deprecated and will always return true.
+* EditPage::getSummaryInput() and ::getSummaryInputOOUI() are deprecated. Please
+  use ::getSummaryInputWidget() instead.
 * Parser::getRandomString() (deprecated in 1.26) was removed.
 * Parser::uniqPrefix() (deprecated in 1.26) was removed.
 * Parser::extractTagsAndParams() now only accepts three arguments. The fourth,
index 0b17e93..40095f1 100644 (file)
@@ -493,7 +493,6 @@ class Block {
                }
 
                $row = $this->getDatabaseArray( $dbw );
-               $row['ipb_id'] = $dbw->nextSequenceValue( "ipblocks_ipb_id_seq" );
 
                $dbw->insert( 'ipblocks', $row, __METHOD__, [ 'IGNORE' ] );
                $affected = $dbw->affectedRows();
index 0c86c1e..fdfa6d9 100644 (file)
@@ -400,11 +400,9 @@ class CommentStore {
                                __METHOD__
                        );
                        if ( !$comment->id ) {
-                               $comment->id = $dbw->nextSequenceValue( 'comment_comment_id_seq' );
                                $dbw->insert(
                                        'comment',
                                        [
-                                               'comment_id' => $comment->id,
                                                'comment_hash' => $hash,
                                                'comment_text' => $comment->text,
                                                'comment_data' => $dbData,
index 2860664..6ea293c 100644 (file)
@@ -3064,9 +3064,51 @@ class EditPage {
                ];
        }
 
+       /**
+        * Standard summary input and label (wgSummary), abstracted so EditPage
+        * subclasses may reorganize the form.
+        * Note that you do not need to worry about the label's for=, it will be
+        * inferred by the id given to the input. You can remove them both by
+        * passing [ 'id' => false ] to $userInputAttrs.
+        *
+        * @deprecated since 1.30 Use getSummaryInputWidget() instead
+        * @param string $summary The value of the summary input
+        * @param string $labelText The html to place inside the label
+        * @param array $inputAttrs Array of attrs to use on the input
+        * @param array $spanLabelAttrs Array of attrs to use on the span inside the label
+        * @return array An array in the format [ $label, $input ]
+        */
+       public function getSummaryInput( $summary = "", $labelText = null,
+               $inputAttrs = null, $spanLabelAttrs = null
+       ) {
+               wfDeprecated( __METHOD__, '1.30' );
+               $inputAttrs = $this->getSummaryInputAttributes( $inputAttrs );
+               $inputAttrs += Linker::tooltipAndAccesskeyAttribs( 'summary' );
+
+               $spanLabelAttrs = ( is_array( $spanLabelAttrs ) ? $spanLabelAttrs : [] ) + [
+                       'class' => $this->missingSummary ? 'mw-summarymissed' : 'mw-summary',
+                       'id' => "wpSummaryLabel"
+               ];
+
+               $label = null;
+               if ( $labelText ) {
+                       $label = Xml::tags(
+                               'label',
+                               $inputAttrs['id'] ? [ 'for' => $inputAttrs['id'] ] : null,
+                               $labelText
+                       );
+                       $label = Xml::tags( 'span', $spanLabelAttrs, $label );
+               }
+
+               $input = Html::input( 'wpSummary', $summary, 'text', $inputAttrs );
+
+               return [ $label, $input ];
+       }
+
        /**
         * Builds a standard summary input with a label.
         *
+        * @deprecated since 1.30 Use getSummaryInputWidget() instead
         * @param string $summary The value of the summary input
         * @param string $labelText The html to place inside the label
         * @param array $inputAttrs Array of attrs to use on the input
@@ -3074,6 +3116,20 @@ class EditPage {
         * @return OOUI\FieldLayout OOUI FieldLayout with Label and Input
         */
        function getSummaryInputOOUI( $summary = "", $labelText = null, $inputAttrs = null ) {
+               wfDeprecated( __METHOD__, '1.30' );
+               $this->getSummaryInputWidget( $summary, $labelText, $inputAttrs );
+       }
+
+       /**
+        * Builds a standard summary input with a label.
+        *
+        * @param string $summary The value of the summary input
+        * @param string $labelText The html to place inside the label
+        * @param array $inputAttrs Array of attrs to use on the input
+        *
+        * @return OOUI\FieldLayout OOUI FieldLayout with Label and Input
+        */
+       function getSummaryInputWidget( $summary = "", $labelText = null, $inputAttrs = null ) {
                $inputAttrs = OOUI\Element::configFromHtmlAttributes(
                        $this->getSummaryInputAttributes( $inputAttrs )
                );
@@ -3122,7 +3178,7 @@ class EditPage {
                }
 
                $labelText = $this->context->msg( $isSubjectPreview ? 'subject' : 'summary' )->parse();
-               $wgOut->addHTML( $this->getSummaryInputOOUI(
+               $wgOut->addHTML( $this->getSummaryInputWidget(
                                $summary,
                                $labelText,
                                [ 'class' => $summaryClass ]
index ff4a284..99d15a7 100644 (file)
@@ -1442,10 +1442,8 @@ class Revision implements IDBAccessObject {
 
                # Record the text (or external storage URL) to the text table
                if ( $this->mTextId === null ) {
-                       $old_id = $dbw->nextSequenceValue( 'text_old_id_seq' );
                        $dbw->insert( 'text',
                                [
-                                       'old_id' => $old_id,
                                        'old_text' => $data,
                                        'old_flags' => $flags,
                                ], __METHOD__
@@ -1458,11 +1456,7 @@ class Revision implements IDBAccessObject {
                }
 
                # Record the edit in revisions
-               $rev_id = $this->mId !== null
-                       ? $this->mId
-                       : $dbw->nextSequenceValue( 'revision_rev_id_seq' );
                $row = [
-                       'rev_id'         => $rev_id,
                        'rev_page'       => $this->mPage,
                        'rev_text_id'    => $this->mTextId,
                        'rev_minor_edit' => $this->mMinorEdit ? 1 : 0,
@@ -1478,6 +1472,9 @@ class Revision implements IDBAccessObject {
                                ? self::base36Sha1( $this->mText )
                                : $this->mSha1,
                ];
+               if ( $this->mId !== null ) {
+                       $row['rev_id'] = $this->mId;
+               }
 
                list( $commentFields, $commentCallback ) =
                        CommentStore::newKey( 'rev_comment' )->insertWithTempTable( $dbw, $this->mComment );
@@ -1508,7 +1505,7 @@ class Revision implements IDBAccessObject {
                $dbw->insert( 'revision', $row, __METHOD__ );
 
                if ( $this->mId === null ) {
-                       // Only if nextSequenceValue() was called
+                       // Only if auto-increment was used
                        $this->mId = $dbw->insertId();
                }
                $commentCallback( $this->mId );
index 588f602..cd11070 100644 (file)
@@ -320,7 +320,6 @@ class RecentChange {
 
                # Fixup database timestamps
                $this->mAttribs['rc_timestamp'] = $dbw->timestamp( $this->mAttribs['rc_timestamp'] );
-               $this->mAttribs['rc_id'] = $dbw->nextSequenceValue( 'recentchanges_rc_id_seq' );
 
                # # If we are using foreign keys, an entry of 0 for the page_id will fail, so use NULL
                if ( $this->mAttribs['rc_cur_id'] == 0 ) {
@@ -333,6 +332,10 @@ class RecentChange {
                unset( $row['rc_comment'], $row['rc_comment_text'], $row['rc_comment_data'] );
                $row += CommentStore::newKey( 'rc_comment' )->insert( $dbw, $comment );
 
+               # Don't reuse an existing rc_id for the new row, if one happens to be
+               # set for some reason.
+               unset( $row['rc_id'] );
+
                # Insert new row
                $dbw->insert( 'recentchanges', $row, __METHOD__ );
 
index 18a87e8..33d4e70 100644 (file)
@@ -548,7 +548,6 @@ class LinksUpdate extends DataUpdate implements EnqueueableDataUpdate {
                foreach ( $diffs as $url => $dummy ) {
                        foreach ( wfMakeUrlIndexes( $url ) as $index ) {
                                $arr[] = [
-                                       'el_id' => $this->getDB()->nextSequenceValue( 'externallinks_el_id_seq' ),
                                        'el_from' => $this->mId,
                                        'el_to' => $url,
                                        'el_index' => $index,
index 6bb1618..e5d36e1 100644 (file)
@@ -92,9 +92,8 @@ class ExternalStoreDB extends ExternalStoreMedium {
 
        public function store( $location, $data ) {
                $dbw = $this->getMaster( $location );
-               $id = $dbw->nextSequenceValue( 'blob_blob_id_seq' );
                $dbw->insert( $this->getTable( $dbw ),
-                       [ 'blob_id' => $id, 'blob_text' => $data ],
+                       [ 'blob_text' => $data ],
                        __METHOD__ );
                $id = $dbw->insertId();
                if ( !$id ) {
index 93a92ef..edb0c9a 100644 (file)
@@ -720,9 +720,7 @@ class WikiRevision {
                                . $this->timestamp . "\n" );
                        return false;
                }
-               $log_id = $dbw->nextSequenceValue( 'logging_log_id_seq' );
                $data = [
-                       'log_id' => $log_id,
                        'log_type' => $this->type,
                        'log_action' => $this->action,
                        'log_timestamp' => $dbw->timestamp( $this->timestamp ),
index b5f331b..b68fdae 100644 (file)
@@ -734,7 +734,6 @@ class JobQueueDB extends JobQueue {
                        'job_title' => $job->getTitle()->getDBkey(),
                        'job_params' => self::makeBlob( $job->getParams() ),
                        // Additional job metadata
-                       'job_id' => $dbw->nextSequenceValue( 'job_job_id_seq' ),
                        'job_timestamp' => $dbw->timestamp(),
                        'job_sha1' => Wikimedia\base_convert(
                                sha1( serialize( $job->getDeduplicationInfo() ) ),
index 736447f..0283c4b 100644 (file)
@@ -420,12 +420,9 @@ interface IDatabase {
        /**
         * Get the inserted value of an auto-increment row
         *
-        * The value inserted should be fetched from nextSequenceValue()
-        *
-        * Example:
-        * $id = $dbw->nextSequenceValue( 'page_page_id_seq' );
-        * $dbw->insert( 'page', [ 'page_id' => $id ] );
-        * $id = $dbw->insertId();
+        * This should only be called after an insert that used an auto-incremented
+        * value. If no such insert was previously done in the current database
+        * session, the return value is undefined.
         *
         * @return int
         */
index 6587304..6197d40 100644 (file)
@@ -596,7 +596,6 @@ class ManualLogEntry extends LogEntryBase {
                global $wgContLang;
 
                $dbw = $dbw ?: wfGetDB( DB_MASTER );
-               $id = $dbw->nextSequenceValue( 'logging_log_id_seq' );
 
                if ( $this->timestamp === null ) {
                        $this->timestamp = wfTimestampNow();
@@ -619,7 +618,6 @@ class ManualLogEntry extends LogEntryBase {
                }
 
                $data = [
-                       'log_id' => $id,
                        'log_type' => $this->getType(),
                        'log_action' => $this->getSubtype(),
                        'log_timestamp' => $dbw->timestamp( $this->getTimestamp() ),
index 257f76d..3b200fa 100644 (file)
@@ -90,12 +90,10 @@ class LogPage {
                global $wgLogRestrictions;
 
                $dbw = wfGetDB( DB_MASTER );
-               $log_id = $dbw->nextSequenceValue( 'logging_log_id_seq' );
 
                // @todo FIXME private/protected/public property?
                $this->timestamp = $now = wfTimestampNow();
                $data = [
-                       'log_id' => $log_id,
                        'log_type' => $this->type,
                        'log_action' => $this->action,
                        'log_timestamp' => $dbw->timestamp( $now ),
index 790845e..5f6e455 100644 (file)
@@ -1166,11 +1166,10 @@ class WikiPage implements Page, IDBAccessObject {
         *   page ID is already in use.
         */
        public function insertOn( $dbw, $pageId = null ) {
-               $pageIdForInsert = $pageId ?: $dbw->nextSequenceValue( 'page_page_id_seq' );
+               $pageIdForInsert = $pageId ? [ 'page_id' => $pageId ] : [];
                $dbw->insert(
                        'page',
                        [
-                               'page_id'           => $pageIdForInsert,
                                'page_namespace'    => $this->mTitle->getNamespace(),
                                'page_title'        => $this->mTitle->getDBkey(),
                                'page_restrictions' => '',
@@ -1180,7 +1179,7 @@ class WikiPage implements Page, IDBAccessObject {
                                'page_touched'      => $dbw->timestamp(),
                                'page_latest'       => 0, // Fill this in shortly...
                                'page_len'          => 0, // Fill this in shortly...
-                       ],
+                       ] + $pageIdForInsert,
                        __METHOD__,
                        'IGNORE'
                );
@@ -2446,7 +2445,6 @@ class WikiPage implements Page, IDBAccessObject {
                                        $dbw->insert(
                                                'page_restrictions',
                                                [
-                                                       'pr_id' => $dbw->nextSequenceValue( 'page_restrictions_pr_id_seq' ),
                                                        'pr_page' => $id,
                                                        'pr_type' => $action,
                                                        'pr_level' => $restrictions,
index e106f37..7fcfbe5 100644 (file)
@@ -214,8 +214,6 @@ class DBSiteStore implements SiteStore {
                                        'sites', $fields, [ 'site_id' => $rowId ], __METHOD__
                                ) && $success;
                        } else {
-                               $rowId = $dbw->nextSequenceValue( 'sites_site_id_seq' );
-                               $fields['site_id'] = $rowId;
                                $success = $dbw->insert( 'sites', $fields, __METHOD__ ) && $success;
                                $rowId = $dbw->insertId();
                        }
index 48477f8..755f9fd 100644 (file)
@@ -290,7 +290,6 @@ class UploadStash {
                }
 
                $this->fileMetadata[$key] = [
-                       'us_id' => $dbw->nextSequenceValue( 'uploadstash_us_id_seq' ),
                        'us_user' => $this->userId,
                        'us_key' => $key,
                        'us_orig_path' => $path,
index 08f054d..8506846 100644 (file)
@@ -4109,12 +4109,10 @@ class User implements IDBAccessObject {
                        unset( $params['options'] );
                }
                $dbw = wfGetDB( DB_MASTER );
-               $seqVal = $dbw->nextSequenceValue( 'user_user_id_seq' );
 
                $noPass = PasswordFactory::newInvalidPassword()->toString();
 
                $fields = [
-                       'user_id' => $seqVal,
                        'user_name' => $name,
                        'user_password' => $noPass,
                        'user_newpassword' => $noPass,
@@ -4179,10 +4177,8 @@ class User implements IDBAccessObject {
                $noPass = PasswordFactory::newInvalidPassword()->toString();
 
                $dbw = wfGetDB( DB_MASTER );
-               $seqVal = $dbw->nextSequenceValue( 'user_user_id_seq' );
                $dbw->insert( 'user',
                        [
-                               'user_id' => $seqVal,
                                'user_name' => $this->mName,
                                'user_password' => $noPass,
                                'user_newpassword' => $noPass,
index 0fae63c..97cd37e 100644 (file)
@@ -68,13 +68,11 @@ class FixExtLinksProtocolRelative extends LoggedUpdateMaintenance {
                        $db->insert( 'externallinks',
                                [
                                        [
-                                               'el_id' => $db->nextSequenceValue( 'externallinks_el_id_seq' ),
                                                'el_from' => $row->el_from,
                                                'el_to' => $row->el_to,
                                                'el_index' => "http:{$row->el_index}",
                                        ],
                                        [
-                                               'el_id' => $db->nextSequenceValue( 'externallinks_el_id_seq' ),
                                                'el_from' => $row->el_from,
                                                'el_to' => $row->el_to,
                                                'el_index' => "https:{$row->el_index}",
index a991d36..0792762 100644 (file)
@@ -3,7 +3,7 @@
  */
 
 /* Remember the collapse state of the legend on recent changes and watchlist pages. */
-( function ( mw, $ ) {
+( function ( mw ) {
        var
                cookieName = 'changeslist-state',
                // Expanded by default
@@ -20,7 +20,5 @@
                                } );
                };
 
-       $( function () {
-               mw.hook( 'wikipage.content' ).add( doCollapsibleLegend );
-       } );
-}( mediaWiki, jQuery ) );
+       mw.hook( 'wikipage.content' ).add( doCollapsibleLegend );
+}( mediaWiki ) );
index b65136a..4e0210a 100644 (file)
@@ -363,7 +363,6 @@ class CommentStoreTest extends MediaWikiLangTestCase {
                                $this->assertArrayNotHasKey( "{$key}_id", $fields, "new field, stage=$writeStage" );
                        }
 
-                       $extraFields[$pk] = $this->db->nextSequenceValue( "{$table}_{$pk}_seq" );
                        $this->db->insert( $table, $extraFields + $fields, __METHOD__ );
                        $id = $this->db->insertId();
                        if ( $usesTemp ) {