Page MenuHomePhabricator

whatlinkshere_for_images.patch

Authored By
bzimport
Nov 21 2014, 6:53 PM
Size
1 KB
Referenced Files
None
Subscribers
None

whatlinkshere_for_images.patch

Index: SpecialWhatlinkshere.php
===================================================================
--- SpecialWhatlinkshere.php (revision 15895)
+++ SpecialWhatlinkshere.php (working copy)
@@ -87,6 +87,9 @@
$dir = 'next';
}
+
+ $isImage = ( $target->getNamespace() == NS_IMAGE );
+
// Make the query
$plConds = array(
'page_id=pl_from',
@@ -100,6 +103,13 @@
'tl_title' => $target->getDBkey(),
);
+ if( $isImage ) {
+ $ilConds = array(
+ 'page_id=il_from',
+ 'il_to' => $target->getDBkey(),
+ );
+ }
+
if ( $from ) {
if ( 'prev' == $dir ) {
$offsetCond = "page_id < $from";
@@ -118,6 +128,10 @@
if ( $offsetCond ) {
$tlConds[] = $offsetCond;
$plConds[] = $offsetCond;
+
+ if( !$isImage ) {
+ $ilConds[] = $offsetCond;
+ }
}
$fields = array( 'page_id', 'page_namespace', 'page_title', 'page_is_redirect' );
@@ -125,8 +139,12 @@
$plConds, $fname, $options );
$tlRes = $dbr->select( array( 'templatelinks', 'page' ), $fields,
$tlConds, $fname, $options );
+ if( $isImage ) {
+ $ilRes = $dbr->select( array( 'imagelinks', 'page' ), $fields,
+ $ilConds, $fname, $options );
+ }
- if ( !$dbr->numRows( $plRes ) && !$dbr->numRows( $tlRes ) ) {
+ if ( !$dbr->numRows( $plRes ) && !$dbr->numRows( $tlRes ) && !( $isImage && $dbr->numRows( $ilRes ) ) ) {
if ( 0 == $level ) {
$wgOut->addWikiText( wfMsg( 'nolinkshere' ) );
}
@@ -147,6 +165,14 @@
}
$dbr->freeResult( $tlRes );
+ if ( $isImage ) {
+ while ( $row = $dbr->fetchObject( $ilRes ) ) {
+ $row->is_template = 0;
+ $rows[$row->page_id] = $row;
+ }
+ $dbr->freeResult( $ilRes );
+ }
+
// Sort by key and then change the keys to 0-based indices
ksort( $rows );
$rows = array_values( $rows );

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1177
Default Alt Text
whatlinkshere_for_images.patch (1 KB)

Event Timeline