r48283 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r48282‎ | r48283 | r48284 >
Date:21:19, 10 March 2009
Author:nad
Status:deferred
Tags:
Comment:
Treat non-existent fields as existing but empty in searches
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
@@ -229,11 +229,15 @@
230230 * Return an array of records given type and other criteria
231231 */
232232 function getRecords( $type, $posted, $wpTitle = '', $invert = false, $orderby = 'created desc' ) {
 233+
 234+ # First get all the articles using the type's template
233235 $records = array();
234236 $dbr = wfGetDB( DB_SLAVE );
235237 $tbl = $dbr->tableName( 'templatelinks' );
236238 $ty = $dbr->addQuotes( $type );
237239 $res = $dbr->select( $tbl, 'tl_from', "tl_namespace = 10 AND tl_title = $ty", __METHOD__ );
 240+
 241+ # Loop through them adding only those that match the regex fields
238242 while ( $row = $dbr->fetchRow( $res ) ) {
239243 $t = Title::newFromID( $row[0] );
240244 if ( empty( $wpTitle ) || eregi( $wpTitle, $t->getPrefixedText() ) ) {
@@ -243,6 +247,7 @@
244248 $r = array( 0 => $t, 'title' => $t->getPrefixedText() );
245249 foreach ( array_keys( $this->types ) as $k ) {
246250 $v = isset( $posted[$k] ) ? ( $this->types[$k] == 'bool' ? 'yes' : $posted[$k] ) : '';
 251+ if ( !preg_match( "|\s*\|\s*$k\s*=|", $text ) ) $text .= "\n|$k=|\n"; # Treat non-existent fields as existing but empty
247252 $i = preg_match( "|\s*\|\s*$k\s*=\s*(.*?)\s*(?=[\|\}])|si", $text, $m );
248253 if ( $v && !( $i && eregi( $v, $m[1] ) ) ) $match = false;
249254 $r[$k] = isset( $m[1] ) ? $m[1] : '';
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.5.5, 2009-03-09' );
 15+define( 'RECORDADMIN_VERSION', '0.5.6, 2009-03-11' );
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