r59650 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r59649‎ | r59650 | r59651 >
Date:01:45, 2 December 2009
Author:nad
Status:deferred
Tags:
Comment:
fix failing $wgRecordAdminAddTitleInfo feature
Modified paths:
  • /trunk/extensions/RecordAdmin/RecordAdmin.php (modified) (history)
  • /trunk/extensions/RecordAdmin/RecordAdmin_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/RecordAdmin/RecordAdmin_body.php
@@ -47,17 +47,16 @@
4848
4949 # Add some hooks if the current title is a record
5050 if ( is_object( $title ) ) {
51 - $types = array();
52 - $id = $title->getArticleID();
53 - $dbr = &wfGetDB( DB_SLAVE );
54 - $cat = $dbr->addQuotes( $wgRecordAdminCategory );
55 - $cl = $dbr->tableName( 'categorylinks' );
56 - $tl = $dbr->tableName( 'templatelinks' );
57 - $res = $dbr->select( $cl, 'cl_from', "cl_to = $cat" );
58 - while ( $row = $dbr->fetchRow( $res ) ) $types[] = 'tl_title = ' . $dbr->addQuotes( Title::newFromID( $row[0] )->getText() );
 51+ $uses = '';
 52+ $id = $title->getArticleID();
 53+ $dbr = &wfGetDB( DB_SLAVE );
 54+ $cat = $dbr->addQuotes( $wgRecordAdminCategory );
 55+ $cl = $dbr->tableName( 'categorylinks' );
 56+ $tl = $dbr->tableName( 'templatelinks' );
 57+ $res = $dbr->select( $cl, 'cl_from', "cl_to = $cat" );
 58+ while ( $row = $dbr->fetchRow( $res ) ) $uses .= " OR tl_title=" . $dbr->addQuotes( Title::newFromID( $row[0] )->getText() );
5959 $dbr->freeResult( $res );
60 - $uses = join( ' OR ', $types );
61 - if ( $uses && $row = $dbr->selectRow( $tl, 'tl_title', "tl_from = $id AND ($uses)" ) ) {
 60+ if ( $uses && $row = $dbr->selectRow( $tl, 'tl_title', "tl_from = $id AND (0 $uses)" ) ) {
6261 global $wgRecordAdminEditWithForm, $wgRecordAdminAddTitleInfo;
6362 $this->type = $row->tl_title;
6463
@@ -855,11 +854,13 @@
856855 }
857856 }
858857 $this->filter = $filter;
 858+ $tmp = $this->type;
859859 $this->preProcessForm( $type );
860860 $this->examineForm();
861861 $records = $this->getRecords( $type, $filter, $title, $invert, $orderby );
862862 if ( $count ) while ( count( $records ) > $count ) array_pop( $records );
863863 $table = $this->renderRecords( $records, $cols, $sortable, $template, $name, $export );
 864+ $this->type = $tmp;
864865
865866 return array( $table, 'noparse' => true, 'isHTML' => true );
866867 }
Index: trunk/extensions/RecordAdmin/RecordAdmin.php
@@ -11,7 +11,7 @@
1212 * @licence GNU General Public Licence 2.0 or later
1313 */
1414
15 -define( 'RECORDADMIN_VERSION', '0.9.0, 2009-11-19' );
 15+define( 'RECORDADMIN_VERSION', '0.9.1, 2009-12-02' );
1616
1717 $wgRecordAdminUseNamespaces = false; # Whether record articles should be in a namespace of the same name as their type
1818 $wgRecordAdminCategory = 'Records'; # Category containing record types

Status & tagging log