X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecialpage%2FChangesListSpecialPage.php;h=282d7642399835a362b71fdc156776467570de30;hb=3d54d208bc0dd54baef18b3891ff0faf1d300214;hp=cb2ae34e358896af625980a177589d02580b84c8;hpb=7b9568f540d93058188cce0d4bf18ce8833b6b64;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specialpage/ChangesListSpecialPage.php b/includes/specialpage/ChangesListSpecialPage.php index cb2ae34e35..eb2cadaee9 100644 --- a/includes/specialpage/ChangesListSpecialPage.php +++ b/includes/specialpage/ChangesListSpecialPage.php @@ -22,7 +22,7 @@ */ use MediaWiki\Logger\LoggerFactory; use Wikimedia\Rdbms\DBQueryTimeoutError; -use Wikimedia\Rdbms\ResultWrapper; +use Wikimedia\Rdbms\IResultWrapper; use Wikimedia\Rdbms\FakeResultWrapper; use Wikimedia\Rdbms\IDatabase; @@ -33,6 +33,12 @@ use Wikimedia\Rdbms\IDatabase; * @ingroup SpecialPage */ abstract class ChangesListSpecialPage extends SpecialPage { + /** + * Maximum length of a tag description in UTF-8 characters. + * Longer descriptions will be truncated. + */ + const TAG_DESC_CHARACTER_LIMIT = 120; + /** * Preference name for saved queries. Subclasses that use saved queries should override this. * @var string @@ -115,7 +121,11 @@ abstract class ChangesListSpecialPage extends SpecialPage { 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds, &$query_options, &$join_conds ) { - $conds[] = 'rc_user = 0'; + $actorMigration = ActorMigration::newMigration(); + $actorQuery = $actorMigration->getJoin( 'rc_user' ); + $tables += $actorQuery['tables']; + $join_conds += $actorQuery['joins']; + $conds[] = $actorMigration->isAnon( $actorQuery['fields']['rc_user'] ); }, 'isReplacedInStructuredUi' => true, @@ -129,7 +139,11 @@ abstract class ChangesListSpecialPage extends SpecialPage { 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds, &$query_options, &$join_conds ) { - $conds[] = 'rc_user != 0'; + $actorMigration = ActorMigration::newMigration(); + $actorQuery = $actorMigration->getJoin( 'rc_user' ); + $tables += $actorQuery['tables']; + $join_conds += $actorQuery['joins']; + $conds[] = $actorMigration->isNotAnon( $actorQuery['fields']['rc_user'] ); }, 'isReplacedInStructuredUi' => true, ] @@ -214,8 +228,10 @@ abstract class ChangesListSpecialPage extends SpecialPage { 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds, &$query_options, &$join_conds ) { - $user = $ctx->getUser(); - $conds[] = 'rc_user_text != ' . $dbr->addQuotes( $user->getName() ); + $actorQuery = ActorMigration::newMigration()->getWhere( $dbr, 'rc_user', $ctx->getUser() ); + $tables += $actorQuery['tables']; + $join_conds += $actorQuery['joins']; + $conds[] = 'NOT(' . $actorQuery['conds'] . ')'; }, 'cssClassSuffix' => 'self', 'isRowApplicableCallable' => function ( $ctx, $rc ) { @@ -230,8 +246,11 @@ abstract class ChangesListSpecialPage extends SpecialPage { 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds, &$query_options, &$join_conds ) { - $user = $ctx->getUser(); - $conds[] = 'rc_user_text = ' . $dbr->addQuotes( $user->getName() ); + $actorQuery = ActorMigration::newMigration() + ->getWhere( $dbr, 'rc_user', $ctx->getUser(), false ); + $tables += $actorQuery['tables']; + $join_conds += $actorQuery['joins']; + $conds[] = $actorQuery['conds']; }, 'cssClassSuffix' => 'others', 'isRowApplicableCallable' => function ( $ctx, $rc ) { @@ -257,7 +276,7 @@ abstract class ChangesListSpecialPage extends SpecialPage { 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds, &$query_options, &$join_conds ) { - $conds[] = 'rc_bot = 0'; + $conds['rc_bot'] = 0; }, 'cssClassSuffix' => 'bot', 'isRowApplicableCallable' => function ( $ctx, $rc ) { @@ -272,7 +291,7 @@ abstract class ChangesListSpecialPage extends SpecialPage { 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds, &$query_options, &$join_conds ) { - $conds[] = 'rc_bot = 1'; + $conds['rc_bot'] = 1; }, 'cssClassSuffix' => 'human', 'isRowApplicableCallable' => function ( $ctx, $rc ) { @@ -471,7 +490,7 @@ abstract class ChangesListSpecialPage extends SpecialPage { 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds, &$query_options, &$join_conds ) { - $conds[] = 'rc_patrolled = 1'; + $conds[] = 'rc_patrolled != 0'; }, 'cssClassSuffix' => 'unpatrolled', 'isRowApplicableCallable' => function ( $ctx, $rc ) { @@ -553,7 +572,7 @@ abstract class ChangesListSpecialPage extends SpecialPage { public function execute( $subpage ) { $this->rcSubpage = $subpage; - $this->considerActionsForDefaultSavedQuery(); + $this->considerActionsForDefaultSavedQuery( $subpage ); $opts = $this->getOptions(); try { @@ -570,8 +589,15 @@ abstract class ChangesListSpecialPage extends SpecialPage { // Used by "live update" and "view newest" to check // if there's new changes with minimal data transfer if ( $this->getRequest()->getBool( 'peek' ) ) { - $code = $rows->numRows() > 0 ? 200 : 204; + $code = $rows->numRows() > 0 ? 200 : 204; $this->getOutput()->setStatusCode( $code ); + + if ( $this->getUser()->isAnon() !== + $this->getRequest()->getFuzzyBool( 'isAnon' ) + ) { + $this->getOutput()->setStatusCode( 205 ); + } + return; } @@ -622,9 +648,11 @@ abstract class ChangesListSpecialPage extends SpecialPage { * Check whether or not the page should load defaults, and if so, whether * a default saved query is relevant to be redirected to. If it is relevant, * redirect properly with all necessary query parameters. + * + * @param string $subpage */ - protected function considerActionsForDefaultSavedQuery() { - if ( !$this->isStructuredFilterUiEnabled() ) { + protected function considerActionsForDefaultSavedQuery( $subpage ) { + if ( !$this->isStructuredFilterUiEnabled() || $this->including() ) { return; } @@ -670,7 +698,7 @@ abstract class ChangesListSpecialPage extends SpecialPage { // but are still valid and requested in the URL $query = array_merge( $this->getRequest()->getValues(), $query ); unset( $query[ 'title' ] ); - $this->getOutput()->redirect( $this->getPageTitle()->getCanonicalURL( $query ) ); + $this->getOutput()->redirect( $this->getPageTitle( $subpage )->getCanonicalURL( $query ) ); } else { // There's a default, but the version is not 2, and the server can't // actually recognize the query itself. This happens if it is before @@ -697,7 +725,7 @@ abstract class ChangesListSpecialPage extends SpecialPage { */ protected function includeRcFiltersApp() { $out = $this->getOutput(); - if ( $this->isStructuredFilterUiEnabled() ) { + if ( $this->isStructuredFilterUiEnabled() && !$this->including() ) { $jsData = $this->getStructuredFilterJsData(); $messages = []; @@ -785,15 +813,15 @@ abstract class ChangesListSpecialPage extends SpecialPage { isset( $explicitlyDefinedTags[ $tagName ] ) || isset( $softwareActivatedTags[ $tagName ] ) ) { - // Parse description - $desc = ChangeTags::tagLongDescriptionMessage( $tagName, $context ); - $result[] = [ 'name' => $tagName, 'label' => Sanitizer::stripAllTags( ChangeTags::tagDescription( $tagName, $context ) ), - 'description' => $desc ? Sanitizer::stripAllTags( $desc->parse() ) : '', + 'description' => + ChangeTags::truncateTagDescription( + $tagName, self::TAG_DESC_CHARACTER_LIMIT, $context + ), 'cssClass' => Sanitizer::escapeClass( 'mw-tag-' . $tagName ), 'hits' => $hits, ]; @@ -829,7 +857,7 @@ abstract class ChangesListSpecialPage extends SpecialPage { */ protected function outputTimeout() { $this->getOutput()->addHTML( - '