r35934 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r35933‎ | r35934 | r35935 >
Date:16:19, 5 June 2008
Author:demon
Status:old
Tags:
Comment:
Bug 13702 - Add Special:MissingFiles to list pages where an [[Image:]] link exists but no appropriate file is there.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/SpecialMissingfiles.php (added) (history)
  • /trunk/phase3/includes/SpecialPage.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/maintenance/language/messages.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/language/messages.inc
@@ -1203,6 +1203,10 @@
12041204 'wantedcategories-summary',
12051205 'wantedpages',
12061206 'wantedpages-summary',
 1207+ 'missingfiles',
 1208+ 'missingfiles-summary',
 1209+ 'missingimages',
 1210+ 'missingimages-summary',
12071211 'mostlinked',
12081212 'mostlinked-summary',
12091213 'mostlinkedcategories',
Index: trunk/phase3/includes/SpecialMissingfiles.php
@@ -0,0 +1,87 @@
 2+<?php
 3+/**
 4+ * A querypage to list the missing files - implements Special:Missingfiles
 5+ *
 6+ * @addtogroup SpecialPage
 7+ *
 8+ * @author Matěj Grabovský <65s.mg@atlas.cz>
 9+ * @copyright Copyright © 2008, Matěj Grabovský
 10+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
 11+ */
 12+class MissingFilesPage extends QueryPage {
 13+ function getName() {
 14+ return 'Missingfiles';
 15+ }
 16+
 17+ function isExpensive() {
 18+ return true;
 19+ }
 20+
 21+ function isSyndicated() {
 22+ return false;
 23+ }
 24+
 25+ function getSQL() {
 26+ $dbr = wfGetDB( DB_SLAVE );
 27+ list( $imagelinks, $page ) = $dbr->tableNamesN( 'imagelinks', 'page' );
 28+ $name = $dbr->addQuotes( $this->getName() );
 29+
 30+ return "SELECT $name as type,
 31+ " . NS_IMAGE . " as namespace,
 32+ il_to as title,
 33+ COUNT(*) as value
 34+ FROM $imagelinks
 35+ LEFT JOIN $page ON il_to = page_title AND page_namespace = ". NS_IMAGE ."
 36+ WHERE page_title IS NULL
 37+ GROUP BY 1,2,3
 38+ ";
 39+ }
 40+
 41+ function sortDescending() {
 42+ return true;
 43+ }
 44+
 45+ /**
 46+ * Fetch user page links and cache their existence
 47+ */
 48+ function preprocessResults( $db, $res ) {
 49+ $batch = new LinkBatch;
 50+
 51+ while ( $row = $db->fetchObject( $res ) )
 52+ $batch->addObj( Title::makeTitleSafe( $row->namespace, $row->title ) );
 53+
 54+ $batch->execute();
 55+
 56+ // Back to start for display
 57+ if ( $db->numRows( $res ) > 0 )
 58+
 59+ // If there are no rows we get an error seeking.
 60+ $db->dataSeek( $res, 0 );
 61+ }
 62+
 63+ public function formatResult( $skin, $result ) {
 64+ global $wgLang, $wgContLang;
 65+
 66+ $nt = Title::makeTitle( $result->namespace, $result->title );
 67+ $text = $wgContLang->convert( $nt->getText() );
 68+
 69+ $plink = $this->isCached()
 70+ ? '<s>' . $skin->makeLinkObj( $nt, htmlspecialchars( $text ) ) . '</s>'
 71+ : $skin->makeBrokenImageLinkObj( $nt, htmlspecialchars( $text ) );
 72+
 73+ $label = wfMsgExt( 'nlinks', array( 'parsemag', 'escape' ), $wgLang->formatNum( $result->value ) );
 74+ $nlinks = $skin->makeKnownLinkObj( SpecialPage::getTitleFor( 'Whatlinkshere' ), $label, 'target=' . $nt->getPrefixedUrl() );
 75+ return wfSpecialList( $plink, $nlinks );
 76+ }
 77+}
 78+
 79+/**
 80+ * Constructor
 81+ */
 82+function wfSpecialMissingFiles() {
 83+ list( $limit, $offset ) = wfCheckLimits();
 84+
 85+ $wpp = new MissingFilesPage();
 86+
 87+ $wpp->doQuery( $offset, $limit );
 88+}
\ No newline at end of file
Property changes on: trunk/phase3/includes/SpecialMissingfiles.php
___________________________________________________________________
Name: svn:eol-style
189 + native
Index: trunk/phase3/includes/DefaultSettings.php
@@ -2627,6 +2627,7 @@
26282628 'Wantedcategories' => 'maintenance',
26292629 'Unwatchedpages' => 'maintenance',
26302630 'Fewestrevisions' => 'maintenance',
 2631+ 'MissingFiles' => 'maintenance',
26312632
26322633 'Userlogin' => 'login',
26332634 'Userlogout' => 'login',
Index: trunk/phase3/includes/SpecialPage.php
@@ -107,6 +107,7 @@
108108 'Unusedimages' => array( 'SpecialPage', 'Unusedimages' ),
109109 'Wantedpages' => array( 'IncludableSpecialPage', 'Wantedpages' ),
110110 'Wantedcategories' => array( 'SpecialPage', 'Wantedcategories' ),
 111+ 'Missingfiles' => array( 'SpecialPage', 'MissingFiles' ),
111112 'Mostlinked' => array( 'SpecialPage', 'Mostlinked' ),
112113 'Mostlinkedcategories' => array( 'SpecialPage', 'Mostlinkedcategories' ),
113114 'Mostlinkedtemplates' => array( 'SpecialPage', 'Mostlinkedtemplates' ),
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -376,6 +376,7 @@
377377 'Unusedimages' => array( 'UnusedImages' ),
378378 'Wantedpages' => array( 'WantedPages', 'BrokenLinks' ),
379379 'Wantedcategories' => array( 'WantedCategories' ),
 380+ 'Missingfiles' => array( 'MissingFiles', 'MissingImages' ),
380381 'Mostlinked' => array( 'MostLinked' ),
381382 'Mostlinkedcategories' => array( 'MostLinkedCategories', 'MostUsedCategories' ),
382383 'Mostlinkedtemplates' => array( 'MostLinkedTemplates', 'MostUsedTemplates' ),
@@ -1875,6 +1876,8 @@
18761877 'wantedcategories-summary' => '', # only translate this message to other languages if you have to change it
18771878 'wantedpages' => 'Wanted pages',
18781879 'wantedpages-summary' => '', # only translate this message to other languages if you have to change it
 1880+'missingfiles' => 'Missing files',
 1881+'missingfiles-summary' => '', # only translate this message to other languages if you have to change it
18791882 'mostlinked' => 'Most linked-to pages',
18801883 'mostlinked-summary' => '', # only translate this message to other languages if you have to change it
18811884 'mostlinkedcategories' => 'Most linked-to categories',
Index: trunk/phase3/RELEASE-NOTES
@@ -143,6 +143,8 @@
144144 * The User class now contains a public function called isActiveEditor. Figures
145145 out if a user is active based on at least $wgActiveUserEditCount number of
146146 edits in the last $wgActiveUserDays days.
 147+* (bug 13702) Add Special:MissingFiles to list places where an image link is
 148+ used but no such file exists.
147149
148150 === Bug fixes in 1.13 ===
149151

Status & tagging log