Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 32 |
|
0.00% |
0 / 7 |
CRAP | |
0.00% |
0 / 1 |
| SpecialMostImages | |
0.00% |
0 / 31 |
|
0.00% |
0 / 7 |
72 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| isExpensive | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| isSyndicated | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getQueryInfo | |
0.00% |
0 / 20 |
|
0.00% |
0 / 1 |
6 | |||
| getCellHtml | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getGroupName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getRecacheDB | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Copyright © 2005 Ævar Arnfjörð Bjarmason |
| 4 | * |
| 5 | * @license GPL-2.0-or-later |
| 6 | * @file |
| 7 | */ |
| 8 | |
| 9 | namespace MediaWiki\Specials; |
| 10 | |
| 11 | use MediaWiki\Deferred\LinksUpdate\ImageLinksTable; |
| 12 | use MediaWiki\MainConfigNames; |
| 13 | use MediaWiki\SpecialPage\ImageQueryPage; |
| 14 | use Wikimedia\Rdbms\IConnectionProvider; |
| 15 | |
| 16 | /** |
| 17 | * List of the most used images. |
| 18 | * |
| 19 | * @ingroup SpecialPage |
| 20 | * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com> |
| 21 | */ |
| 22 | class SpecialMostImages extends ImageQueryPage { |
| 23 | |
| 24 | private int $imageLinksMigrationStage; |
| 25 | |
| 26 | public function __construct( IConnectionProvider $dbProvider ) { |
| 27 | parent::__construct( 'Mostimages' ); |
| 28 | $this->setDatabaseProvider( $dbProvider ); |
| 29 | $this->imageLinksMigrationStage = $this->getConfig()->get( MainConfigNames::ImageLinksSchemaMigrationStage ); |
| 30 | } |
| 31 | |
| 32 | /** @inheritDoc */ |
| 33 | public function isExpensive() { |
| 34 | return true; |
| 35 | } |
| 36 | |
| 37 | /** @inheritDoc */ |
| 38 | public function isSyndicated() { |
| 39 | return false; |
| 40 | } |
| 41 | |
| 42 | /** @inheritDoc */ |
| 43 | public function getQueryInfo() { |
| 44 | if ( $this->imageLinksMigrationStage & SCHEMA_COMPAT_READ_OLD ) { |
| 45 | $linksTables = [ 'imagelinks' ]; |
| 46 | $titleField = 'il_to'; |
| 47 | $joinConds = []; |
| 48 | } else { |
| 49 | $linksTables = [ 'imagelinks', 'linktarget' ]; |
| 50 | $titleField = 'lt_title'; |
| 51 | $joinConds = [ 'linktarget' => [ 'JOIN', 'il_target_id = lt_id' ] ]; |
| 52 | } |
| 53 | |
| 54 | return [ |
| 55 | 'tables' => $linksTables, |
| 56 | 'fields' => [ |
| 57 | 'namespace' => NS_FILE, |
| 58 | 'title' => $titleField, |
| 59 | 'value' => 'COUNT(*)' |
| 60 | ], |
| 61 | 'join_conds' => $joinConds, |
| 62 | 'options' => [ |
| 63 | 'GROUP BY' => $titleField, |
| 64 | 'HAVING' => 'COUNT(*) > 1' |
| 65 | ] |
| 66 | ]; |
| 67 | } |
| 68 | |
| 69 | /** @inheritDoc */ |
| 70 | protected function getCellHtml( $row ) { |
| 71 | return $this->msg( 'nimagelinks' )->numParams( $row->value )->escaped() . '<br />'; |
| 72 | } |
| 73 | |
| 74 | /** @inheritDoc */ |
| 75 | protected function getGroupName() { |
| 76 | return 'highuse'; |
| 77 | } |
| 78 | |
| 79 | /** @inheritDoc */ |
| 80 | protected function getRecacheDB() { |
| 81 | return $this->getDatabaseProvider()->getReplicaDatabase( |
| 82 | ImageLinksTable::VIRTUAL_DOMAIN, |
| 83 | 'vslow' |
| 84 | ); |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * Retain the old class name for backwards compatibility. |
| 90 | * @deprecated since 1.40 |
| 91 | */ |
| 92 | class_alias( SpecialMostImages::class, 'MostimagesPage' ); |