X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fspecials%2Fpagers%2FImageListPager.php;h=bb4f0b3432d35338c72fecd75e3d04937fc97e68;hp=d80946a5443aa33c12c419d9b81493059119c20e;hb=141cb4865421b6063bf4dc0994867d1d2a3d87f7;hpb=255d76f2a13a8378ded9f0cf1c2bb172f7f07a5b diff --git a/includes/specials/pagers/ImageListPager.php b/includes/specials/pagers/ImageListPager.php index d80946a544..bb4f0b3432 100644 --- a/includes/specials/pagers/ImageListPager.php +++ b/includes/specials/pagers/ImageListPager.php @@ -23,7 +23,7 @@ * @ingroup Pager */ use MediaWiki\MediaWikiServices; -use Wikimedia\Rdbms\ResultWrapper; +use Wikimedia\Rdbms\IResultWrapper; use Wikimedia\Rdbms\FakeResultWrapper; class ImageListPager extends TablePager { @@ -134,7 +134,14 @@ class ImageListPager extends TablePager { $conds = []; if ( !is_null( $this->mUserName ) ) { - $conds[$prefix . '_user_text'] = $this->mUserName; + // getQueryInfoReal() should have handled the tables and joins. + $dbr = wfGetDB( DB_REPLICA ); + $actorWhere = ActorMigration::newMigration()->getWhere( + $dbr, + $prefix . '_user', + User::newFromName( $this->mUserName, false ) + ); + $conds[] = $actorWhere['conds']; } if ( $this->mSearch !== '' ) { @@ -193,9 +200,9 @@ class ImageListPager extends TablePager { } $sortable = [ 'img_timestamp', 'img_name', 'img_size' ]; /* For reference, the indicies we can use for sorting are: - * On the image table: img_user_timestamp, img_usertext_timestamp, + * On the image table: img_user_timestamp/img_usertext_timestamp/img_actor_timestamp, * img_size, img_timestamp - * On oldimage: oi_usertext_timestamp, oi_name_timestamp + * On oldimage: oi_usertext_timestamp/oi_actor_timestamp, oi_name_timestamp * * In particular that means we cannot sort by timestamp when not filtering * by user and including old images in the results. Which is sad. @@ -246,6 +253,7 @@ class ImageListPager extends TablePager { $tables = [ $table ]; $fields = $this->getFieldNames(); unset( $fields['img_description'] ); + unset( $fields['img_user_text'] ); $fields = array_keys( $fields ); if ( $table === 'oldimage' ) { @@ -261,18 +269,25 @@ class ImageListPager extends TablePager { $fields[array_search( 'top', $fields )] = "'yes' AS top"; } } - $fields[] = $prefix . '_user AS img_user'; $fields[array_search( 'thumb', $fields )] = $prefix . '_name AS thumb'; $options = $join_conds = []; # Description field - $commentQuery = CommentStore::newKey( $prefix . '_description' )->getJoin(); + $commentQuery = CommentStore::getStore()->getJoin( $prefix . '_description' ); $tables += $commentQuery['tables']; $fields += $commentQuery['fields']; $join_conds += $commentQuery['joins']; $fields['description_field'] = "'{$prefix}_description'"; + # User fields + $actorQuery = ActorMigration::newMigration()->getJoin( $prefix . '_user' ); + $tables += $actorQuery['tables']; + $join_conds += $actorQuery['joins']; + $fields['img_user'] = $actorQuery['fields'][$prefix . '_user']; + $fields['img_user_text'] = $actorQuery['fields'][$prefix . '_user_text']; + $fields['img_actor'] = $actorQuery['fields'][$prefix . '_actor']; + # Depends on $wgMiserMode # Will also not happen if mShowAll is true. if ( isset( $this->mFieldNames['count'] ) ) { @@ -287,7 +302,7 @@ class ImageListPager extends TablePager { unset( $field ); $columnlist = preg_grep( '/^img/', array_keys( $this->getFieldNames() ) ); - $options = [ 'GROUP BY' => array_merge( [ 'img_user' ], $columnlist ) ]; + $options = [ 'GROUP BY' => array_merge( [ $fields['img_user'] ], $columnlist ) ]; $join_conds['oldimage'] = [ 'LEFT JOIN', 'oi_name = img_name' ]; } @@ -348,8 +363,8 @@ class ImageListPager extends TablePager { * * Note: This will throw away some results * - * @param ResultWrapper $res1 - * @param ResultWrapper $res2 + * @param IResultWrapper $res1 + * @param IResultWrapper $res2 * @param int $limit * @param bool $ascending See note about $asc in $this->reallyDoQuery * @return FakeResultWrapper $res1 and $res2 combined @@ -498,7 +513,7 @@ class ImageListPager extends TablePager { return htmlspecialchars( $this->getLanguage()->formatSize( $value ) ); case 'img_description': $field = $this->mCurrentRow->description_field; - $value = CommentStore::newKey( $field )->getComment( $this->mCurrentRow )->text; + $value = CommentStore::getStore()->getComment( $field, $this->mCurrentRow )->text; return Linker::formatComment( $value ); case 'count': return $this->getLanguage()->formatNum( intval( $value ) + 1 );