X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fspecials%2Fpagers%2FNewPagesPager.php;h=c50563d7cd6f6e348225cf46c4871fda7a6597a3;hp=5788bb2bacfac4d10ee94f8bc6a16ad856e30cb3;hb=fa0f6f34972c0e0f4aac24a03b3efdfc45f256f6;hpb=b8e0ca16aa743581f5fac5cef8bed5ac2bf6e7cb diff --git a/includes/specials/pagers/NewPagesPager.php b/includes/specials/pagers/NewPagesPager.php index 5788bb2bac..c50563d7cd 100644 --- a/includes/specials/pagers/NewPagesPager.php +++ b/includes/specials/pagers/NewPagesPager.php @@ -22,6 +22,8 @@ /** * @ingroup Pager */ +use MediaWiki\MediaWikiServices; + class NewPagesPager extends ReverseChronologicalPager { /** @@ -50,9 +52,6 @@ class NewPagesPager extends ReverseChronologicalPager { $conds = []; $conds['rc_new'] = 1; - $namespace = $this->opts->getValue( 'namespace' ); - $namespace = ( $namespace === 'all' ) ? false : intval( $namespace ); - $username = $this->opts->getValue( 'username' ); $user = Title::makeTitleSafe( NS_USER, $username ); @@ -65,25 +64,21 @@ class NewPagesPager extends ReverseChronologicalPager { } } - if ( $namespace !== false ) { - if ( $this->opts->getValue( 'invert' ) ) { - $conds[] = 'rc_namespace != ' . $this->mDb->addQuotes( $namespace ); - } else { - $conds['rc_namespace'] = $namespace; - } - } - if ( $user ) { $conds[] = ActorMigration::newMigration()->getWhere( $this->mDb, 'rc_user', User::newFromName( $user->getText(), false ), false )['conds']; - } elseif ( User::groupHasPermission( '*', 'createpage' ) && + } elseif ( MediaWikiServices::getInstance() + ->getPermissionManager() + ->groupHasPermission( '*', 'createpage' ) && $this->opts->getValue( 'hideliu' ) ) { # If anons cannot make new pages, don't "exclude logged in users"! $conds[] = ActorMigration::newMigration()->isAnon( $rcQuery['fields']['rc_user'] ); } + $conds = array_merge( $conds, $this->getNamespaceCond() ); + # If this user cannot see patrolled edits or they are off, don't do dumb queries! if ( $this->opts->getValue( 'hidepatrolled' ) && $this->getUser()->useNPPatrol() ) { $conds['rc_patrolled'] = RecentChange::PRC_UNPATROLLED; @@ -130,6 +125,32 @@ class NewPagesPager extends ReverseChronologicalPager { return $info; } + // Based on ContribsPager.php + function getNamespaceCond() { + $namespace = $this->opts->getValue( 'namespace' ); + if ( $namespace === 'all' || $namespace === '' ) { + return []; + } + + $namespace = intval( $namespace ); + $invert = $this->opts->getValue( 'invert' ); + $associated = $this->opts->getValue( 'associated' ); + + $eq_op = $invert ? '!=' : '='; + $bool_op = $invert ? 'AND' : 'OR'; + + if ( !$associated ) { + return [ "rc_namespace $eq_op " . $this->mDb->addQuotes( $namespace ) ]; + } + + $associatedNS = MediaWikiServices::getInstance()->getNamespaceInfo()->getAssociated( $namespace ); + return [ + "rc_namespace $eq_op " . $this->mDb->addQuotes( $namespace ) . + $bool_op . + " rc_namespace $eq_op " . $this->mDb->addQuotes( $associatedNS ) + ]; + } + function getIndexField() { return 'rc_timestamp'; }