X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecials%2Fpagers%2FImageListPager.php;h=d80946a5443aa33c12c419d9b81493059119c20e;hb=74426f3cf796b149f1ae445e41815bbe148640b2;hp=4c1e8eebf4b65a223a4d22053c24a6bad6349d56;hpb=5300df4838f68437c17d5d697de57a46f0b5e02c;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/pagers/ImageListPager.php b/includes/specials/pagers/ImageListPager.php index 4c1e8eebf4..d80946a544 100644 --- a/includes/specials/pagers/ImageListPager.php +++ b/includes/specials/pagers/ImageListPager.php @@ -23,6 +23,8 @@ * @ingroup Pager */ use MediaWiki\MediaWikiServices; +use Wikimedia\Rdbms\ResultWrapper; +use Wikimedia\Rdbms\FakeResultWrapper; class ImageListPager extends TablePager { @@ -191,7 +193,8 @@ 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_usertext_timestamp, img_size, img_timestamp + * On the image table: img_user_timestamp, img_usertext_timestamp, + * img_size, img_timestamp * On oldimage: oi_usertext_timestamp, oi_name_timestamp * * In particular that means we cannot sort by timestamp when not filtering @@ -241,7 +244,9 @@ class ImageListPager extends TablePager { $prefix = $table === 'oldimage' ? 'oi' : 'img'; $tables = [ $table ]; - $fields = array_keys( $this->getFieldNames() ); + $fields = $this->getFieldNames(); + unset( $fields['img_description'] ); + $fields = array_keys( $fields ); if ( $table === 'oldimage' ) { foreach ( $fields as $id => &$field ) { @@ -261,6 +266,13 @@ class ImageListPager extends TablePager { $options = $join_conds = []; + # Description field + $commentQuery = CommentStore::newKey( $prefix . '_description' )->getJoin(); + $tables += $commentQuery['tables']; + $fields += $commentQuery['fields']; + $join_conds += $commentQuery['joins']; + $fields['description_field'] = "'{$prefix}_description'"; + # Depends on $wgMiserMode # Will also not happen if mShowAll is true. if ( isset( $this->mFieldNames['count'] ) ) { @@ -274,14 +286,9 @@ class ImageListPager extends TablePager { } unset( $field ); - $dbr = wfGetDB( DB_REPLICA ); - if ( $dbr->implicitGroupby() ) { - $options = [ 'GROUP BY' => 'img_name' ]; - } else { - $columnlist = preg_grep( '/^img/', array_keys( $this->getFieldNames() ) ); - $options = [ 'GROUP BY' => array_merge( [ 'img_user' ], $columnlist ) ]; - } - $join_conds = [ 'oldimage' => [ 'LEFT JOIN', 'oi_name = img_name' ] ]; + $columnlist = preg_grep( '/^img/', array_keys( $this->getFieldNames() ) ); + $options = [ 'GROUP BY' => array_merge( [ 'img_user' ], $columnlist ) ]; + $join_conds['oldimage'] = [ 'LEFT JOIN', 'oi_name = img_name' ]; } return [ @@ -373,16 +380,12 @@ class ImageListPager extends TablePager { } } - // @codingStandardsIgnoreStart Squiz.WhiteSpace.SemicolonSpacing.Incorrect for ( ; $i < $limit && $topRes1; $i++ ) { - // @codingStandardsIgnoreEnd $resultArray[] = $topRes1; $topRes1 = $res1->next(); } - // @codingStandardsIgnoreStart Squiz.WhiteSpace.SemicolonSpacing.Incorrect for ( ; $i < $limit && $topRes2; $i++ ) { - // @codingStandardsIgnoreEnd $resultArray[] = $topRes2; $topRes2 = $res2->next(); } @@ -494,6 +497,8 @@ class ImageListPager extends TablePager { case 'img_size': return htmlspecialchars( $this->getLanguage()->formatSize( $value ) ); case 'img_description': + $field = $this->mCurrentRow->description_field; + $value = CommentStore::newKey( $field )->getComment( $this->mCurrentRow )->text; return Linker::formatComment( $value ); case 'count': return $this->getLanguage()->formatNum( intval( $value ) + 1 );