Merge "EditPage: Deprecate getCheckboxes() and getCheckboxesOOUI()"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 5 Sep 2017 06:23:55 +0000 (06:23 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 5 Sep 2017 06:23:55 +0000 (06:23 +0000)
1  2 
RELEASE-NOTES-1.30
includes/EditPage.php

diff --combined RELEASE-NOTES-1.30
@@@ -61,11 -61,6 +61,11 @@@ section)
    just been unwatched.
  * Added $wgParserTestMediaHandlers, where mock media handlers can be passed to
    MediaHandlerFactory for parser tests.
 +* Edit summaries, block reasons, and other "comments" are now stored in a
 +  separate database table. Use the CommentFormatter class to access them.
 +** This is currently gated by $wgCommentTableSchemaMigrationStage. Most wikis
 +   can set this to MIGRATION_NEW and run maintenance/migrateComments.php as
 +   soon as any necessary extensions are updated.
  
  === External library changes in 1.30 ===
  
@@@ -157,7 -152,6 +157,7 @@@ changes to languages because of Phabric
    WikiPage::makeParserOptions() to create the ParserOptions object and only
    change options that affect the parser cache key.
  * Article::viewRedirect() is deprecated.
 +* IP::isValidBlock() was deprecated. Use the equivalent IP::isValidRange().
  * DeprecatedGlobal no longer supports passing in a direct value, it requires a
    callable factory function or a class name.
  * The $parserMemc global, wfGetParserCacheStorage(), and ParserCache::singleton()
  * EditPage::isOouiEnabled() is deprecated and will always return true.
  * EditPage::getSummaryInput() and ::getSummaryInputOOUI() are deprecated. Please
    use ::getSummaryInputWidget() instead.
+ * EditPage::getCheckboxes() and ::getCheckboxesOOUI() are deprecated. Please
+   use ::getCheckboxesWidget() 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,
 +* Parser::extractTagsAndParams() now only accepts three arguments. The fourth,
    $uniq_prefix was deprecated in 1.26 and has now been removed.
 +* (T172514) The following tables have had their UNIQUE indexes turned into proper
 +  PRIMARY KEYs for increased maintainability: categorylinks, imagelinks, iwlinks,
 +  langlinks, log_search, module_deps, objectcache, pagelinks, query_cache, site_stats,
 +  templatelinks, text, transcache, user_former_groups, user_properties.
 +* IDatabase::nextSequenceValue() is no longer needed by any database backends
 +  (formerly it was needed by PostgreSQL and Oracle), and is now deprecated.
  
  == Compatibility ==
  MediaWiki 1.30 requires PHP 5.5.9 or later. There is experimental support for
diff --combined includes/EditPage.php
@@@ -2658,7 -2658,8 +2658,7 @@@ class EditPage 
                $wgOut->addHTML( Html::openElement(
                        'form',
                        [
 -                              // Keep mw-editform-ooui class for backwards-compatibility temporarily
 -                              'class' => 'mw-editform mw-editform-ooui',
 +                              'class' => 'mw-editform',
                                'id' => self::EDITFORM_ID,
                                'name' => self::EDITFORM_ID,
                                'method' => 'post',
  
                if ( $this->wasDeletedSinceLastEdit() && 'save' == $this->formtype ) {
                        $username = $this->lastDelete->user_name;
 -                      $comment = $this->lastDelete->log_comment;
 +                      $comment = CommentStore::newKey( 'log_comment' )->getComment( $this->lastDelete )->text;
  
                        // It is better to not parse the comment at all than to have templates expanded in the middle
                        // TODO: can the checkLabel be moved outside of the div so that wrapWikiMsg could be used?
                $wgOut->addHTML( Html::hidden( 'wpStarttime', $this->starttime ) );
                $wgOut->addHTML( Html::hidden( 'wpEdittime', $this->edittime ) );
                $wgOut->addHTML( Html::hidden( 'editRevId', $this->editRevId ) );
 -              $wgOut->addHTML( Html::hidden( 'wpScrolltop', $this->scrolltop ) );
 +              $wgOut->addHTML( Html::hidden( 'wpScrolltop', $this->scrolltop, [ 'id' => 'wpScrolltop' ] ) );
  
                if ( !$this->checkUnicodeCompliantBrowser() ) {
                        $wgOut->addHTML( Html::hidden( 'safemode', '1' ) );
                        $wgOut->addHTML( $this->getSummaryPreview( false, $this->summary ) );
                }
  
-               $checkboxes = $this->getCheckboxesOOUI(
+               $checkboxes = $this->getCheckboxesWidget(
                        $tabindex,
                        [ 'minor' => $this->minoredit, 'watch' => $this->watchthis ]
                );
         */
        protected function getLastDelete() {
                $dbr = wfGetDB( DB_REPLICA );
 +              $commentQuery = CommentStore::newKey( 'log_comment' )->getJoin();
                $data = $dbr->selectRow(
 -                      [ 'logging', 'user' ],
 +                      [ 'logging', 'user' ] + $commentQuery['tables'],
                        [
                                'log_type',
                                'log_action',
                                'log_user',
                                'log_namespace',
                                'log_title',
 -                              'log_comment',
                                'log_params',
                                'log_deleted',
                                'user_name'
 -                      ], [
 +                      ] + $commentQuery['fields'], [
                                'log_namespace' => $this->mTitle->getNamespace(),
                                'log_title' => $this->mTitle->getDBkey(),
                                'log_type' => 'delete',
                                'user_id=log_user'
                        ],
                        __METHOD__,
 -                      [ 'LIMIT' => 1, 'ORDER BY' => 'log_timestamp DESC' ]
 +                      [ 'LIMIT' => 1, 'ORDER BY' => 'log_timestamp DESC' ],
 +                      [
 +                              'user' => [ 'JOIN', 'user_id=log_user' ],
 +                      ] + $commentQuery['joins']
                );
                // Quick paranoid permission checks...
                if ( is_object( $data ) ) {
                        }
  
                        if ( $data->log_deleted & LogPage::DELETED_COMMENT ) {
 -                              $data->log_comment = $this->context->msg( 'rev-deleted-comment' )->escaped();
 +                              $data->log_comment_text = $this->context->msg( 'rev-deleted-comment' )->escaped();
 +                              $data->log_comment_data = null;
                        }
                }
  
         *   where bool indicates the checked status of the checkbox
         * @return array
         */
 -      protected function getCheckboxesDefinition( $checked ) {
 +      public function getCheckboxesDefinition( $checked ) {
                global $wgUser;
                $checkboxes = [];
  
         * Returns an array of html code of the following checkboxes old style:
         * minor and watch
         *
+        * @deprecated since 1.30 Use getCheckboxesWidget() or getCheckboxesDefinition() instead
         * @param int &$tabindex Current tabindex
         * @param array $checked See getCheckboxesDefinition()
         * @return array
        }
  
        /**
-        * Returns an array of html code of the following checkboxes:
-        * minor and watch
+        * Returns an array of checkboxes for the edit form, including 'minor' and 'watch' checkboxes and
+        * any other added by extensions.
         *
+        * @deprecated since 1.30 Use getCheckboxesWidget() or getCheckboxesDefinition() instead
         * @param int &$tabindex Current tabindex
         * @param array $checked Array of checkbox => bool, where bool indicates the checked
         *                 status of the checkbox
         *
-        * @return array
+        * @return array Associative array of string keys to OOUI\FieldLayout instances
         */
        public function getCheckboxesOOUI( &$tabindex, $checked ) {
+               return $this->getCheckboxesWidget( $tabindex, $checked );
+       }
+       /**
+        * Returns an array of checkboxes for the edit form, including 'minor' and 'watch' checkboxes and
+        * any other added by extensions.
+        *
+        * @param int &$tabindex Current tabindex
+        * @param array $checked Array of checkbox => bool, where bool indicates the checked
+        *                 status of the checkbox
+        *
+        * @return array Associative array of string keys to OOUI\FieldLayout instances
+        */
+       public function getCheckboxesWidget( &$tabindex, $checked ) {
                $checkboxes = [];
                $checkboxesDef = $this->getCheckboxesDefinition( $checked );
  
-               $origTabindex = $tabindex;
                foreach ( $checkboxesDef as $name => $options ) {
                        $legacyName = isset( $options['legacy-name'] ) ? $options['legacy-name'] : $name;
  
                        if ( isset( $options['title-message'] ) ) {
                                $title = $this->context->msg( $options['title-message'] )->text();
                        }
 -                      if ( isset( $options['label-id'] ) ) {
 -                              $labelAttribs['id'] = $options['label-id'];
 -                      }
  
                        $checkboxes[ $legacyName ] = new OOUI\FieldLayout(
                                new OOUI\CheckboxInputWidget( [
                // Backwards-compatibility hack to run the EditPageBeforeEditChecks hook. It's important,
                // people have used it for the weirdest things completely unrelated to checkboxes...
                // And if we're gonna run it, might as well allow its legacy checkboxes to be shown.
-               $legacyCheckboxes = $this->getCheckboxes( $origTabindex, $checked );
+               $legacyCheckboxes = [];
+               if ( !$this->isNew ) {
+                       $legacyCheckboxes['minor'] = '';
+               }
+               $legacyCheckboxes['watch'] = '';
+               // Copy new-style checkboxes into an old-style structure
+               foreach ( $checkboxes as $name => $oouiLayout ) {
+                       $legacyCheckboxes[$name] = (string)$oouiLayout;
+               }
+               // Avoid PHP 7.1 warning of passing $this by reference
+               $ep = $this;
+               Hooks::run( 'EditPageBeforeEditChecks', [ &$ep, &$legacyCheckboxes, &$tabindex ], '1.29' );
+               // Copy back any additional old-style checkboxes into the new-style structure
                foreach ( $legacyCheckboxes as $name => $html ) {
                        if ( $html && !isset( $checkboxes[$name] ) ) {
                                $checkboxes[$name] = new OOUI\Widget( [ 'content' => new OOUI\HtmlSnippet( $html ) ] );