r86091 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86090‎ | r86091 | r86092 >
Date:22:48, 14 April 2011
Author:reedy
Status:deferred
Tags:
Comment:
Fix up some strict errors

Swap some assignment in conditional from while to foreach loop
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_String.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_URI.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/export/SMW_Exp_Element.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/export/SMW_ExportController.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_CSV.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_Category.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_DSV.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_Embedded.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_List.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_RDF.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_RSSlink.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLHelpers.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStoreLight.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_SpecialAsk.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_SpecialAsk.php
@@ -49,7 +49,7 @@
5050 $format = $wgRequest->getVal( 'showformatoptions' );
5151 $params = $wgRequest->getArray( 'params' );
5252 $wgOut->disable();
53 - echo self::showFormatOptions( $format, $params );
 53+ echo $this->showFormatOptions( $format, $params );
5454 } else {
5555 $this->extractQueryParameters( $p );
5656 $this->makeHTMLResult();
@@ -578,7 +578,7 @@
579579
580580 $result .= "</select></p>\n";
581581 $result .= '<fieldset><legend>' . wfMsg( 'smw_ask_otheroptions' ) . "</legend>\n";
582 - $result .= "<div id=\"other_options\">" . self::showFormatOptions( $this->m_params['format'], $this->m_params ) . "</div>";
 582+ $result .= "<div id=\"other_options\">" . $this->showFormatOptions( $this->m_params['format'], $this->m_params ) . "</div>";
583583 $result .= "</fieldset>\n";
584584 $urltail = str_replace( '&eq=yes', '', $urltail ) . '&eq=no';
585585
Index: trunk/extensions/SemanticMediaWiki/includes/export/SMW_Exp_Element.php
@@ -77,9 +77,9 @@
7878 $this->m_namespace = $namespace;
7979 $this->m_namespaceid = $namespaceid;
8080 $this->m_localname = $name;
81 - SMWExpElement::__construct( $namespace . $name, $dv );
 81+ parent::__construct( $namespace . $name, $dv );
8282 } else {
83 - SMWExpElement::__construct( $name, $dv );
 83+ parent::__construct( $name, $dv );
8484 }
8585 }
8686
@@ -142,7 +142,7 @@
143143 */
144144 public function __construct( $name, $dv = null, $datatype = false ) {
145145 $this->m_datatype = $datatype;
146 - SMWExpElement::__construct( $name, $dv );
 146+ parent::__construct( $name, $dv );
147147 }
148148
149149 /**
Index: trunk/extensions/SemanticMediaWiki/includes/export/SMW_ExportController.php
@@ -510,7 +510,7 @@
511511 , 'SMW::RDF::PrintPageList', array( 'ORDER BY' => 'page_id ASC', 'OFFSET' => $offset, 'LIMIT' => $limit ) );
512512 $foundpages = false;
513513
514 - while ( $row = $db->fetchObject( $res ) ) {
 514+ foreach ( $res as $row ) {
515515 $foundpages = true;
516516 $st = new SMWSmallTitle();
517517 $st->dbkey = $row->page_title;
Index: trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_URI.php
@@ -36,8 +36,8 @@
3737 return SMWDataValue::TYPE_URI;
3838 }
3939
40 - public function SMWURIValue( $typeid ) {
41 - SMWDataValue::__construct( $typeid );
 40+ public function __construct( $typeid ) {
 41+ parent::__construct( $typeid );
4242 switch ( $typeid ) {
4343 case '_ema':
4444 $this->m_mode = SMW_URI_MODE_EMAIL;
Index: trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_String.php
@@ -116,7 +116,7 @@
117117 public function getInfolinks() {
118118 $this->unstub();
119119 if ( ( $this->m_typeid != '_txt' ) && ( $this->m_typeid != '_cod' ) ) {
120 - return SMWDataValue::getInfolinks();
 120+ return parent::getInfolinks();
121121 } else {
122122 return $this->m_infolinks;
123123 }
Index: trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_RSSlink.php
@@ -17,7 +17,7 @@
1818 protected $m_description = '';
1919
2020 protected function readParameters( $params, $outputmode ) {
21 - SMWResultPrinter::readParameters( $params, $outputmode );
 21+ parent::readParameters( $params, $outputmode );
2222 if ( array_key_exists( 'title', $this->m_params ) ) {
2323 $this->m_title = trim( $this->m_params['title'] );
2424 // for backward compatibiliy
Index: trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_Embedded.php
@@ -23,7 +23,7 @@
2424 protected $m_embedformat;
2525
2626 protected function readParameters( $params, $outputmode ) {
27 - SMWResultPrinter::readParameters( $params, $outputmode );
 27+ parent::readParameters( $params, $outputmode );
2828
2929 $this->m_showhead = !array_key_exists( 'embedonly', $params );
3030 $this->m_embedformat = array_key_exists( 'embedformat', $params ) ? trim( $params['embedformat'] ) : 'h1';
Index: trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_CSV.php
@@ -15,7 +15,7 @@
1616 protected $m_sep;
1717
1818 protected function readParameters( $params, $outputmode ) {
19 - SMWResultPrinter::readParameters( $params, $outputmode );
 19+ parent::readParameters( $params, $outputmode );
2020 if ( array_key_exists( 'sep', $params ) ) {
2121 $this->m_sep = str_replace( '_', ' ', $params['sep'] );
2222 } else {
Index: trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_List.php
@@ -26,7 +26,7 @@
2727 protected $mOutroTemplate = '';
2828
2929 protected function readParameters( $params, $outputmode ) {
30 - SMWResultPrinter::readParameters( $params, $outputmode );
 30+ parent::readParameters( $params, $outputmode );
3131
3232 if ( array_key_exists( 'sep', $params ) ) {
3333 $this->mSep = str_replace( '_', ' ', $params['sep'] );
Index: trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_RDF.php
@@ -18,7 +18,7 @@
1919 protected $syntax;
2020
2121 protected function readParameters( $params, $outputmode ) {
22 - SMWResultPrinter::readParameters( $params, $outputmode );
 22+ parent::readParameters( $params, $outputmode );
2323 if ( array_key_exists( 'syntax', $params ) ) {
2424 $this->syntax = $params['syntax'];
2525 } else {
Index: trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_DSV.php
@@ -18,7 +18,7 @@
1919 protected $fileName = 'result.dsv';
2020
2121 protected function readParameters( $params, $outputmode ) {
22 - SMWResultPrinter::readParameters( $params, $outputmode );
 22+ parent::readParameters( $params, $outputmode );
2323
2424 if ( array_key_exists( 'separator', $this->m_params ) && $this->m_params['separator'] != '\\' ) {
2525 $this->separator = trim( $this->m_params['separator'] );
Index: trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_Category.php
@@ -22,7 +22,7 @@
2323 protected $mNumColumns = 3;
2424
2525 protected function readParameters( $params, $outputmode ) {
26 - SMWResultPrinter::readParameters( $params, $outputmode );
 26+ parent::readParameters( $params, $outputmode );
2727
2828 if ( array_key_exists( 'delim', $params ) ) {
2929 $this->mDelim = str_replace( '_', ' ', $params['delim'] );
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStoreLight.php
@@ -87,7 +87,7 @@
8888 }
8989 $res = $db->select( $tablename, array( 'propname', 'value' ), array( 'pageid' => $sid ),
9090 'SMW::getSemanticData', array( 'DISTINCT' ) );
91 - while ( $row = $db->fetchObject( $res ) ) {
 91+ foreach ( $res as $row ) {
9292 $value = ( $tablename == 'smwsimple_special' ) ? array( $row->value ) : unserialize( $row->value );
9393 $this->m_semdata[$sid]->addPropertyStubValue( $row->propname, $value );
9494 }
@@ -124,7 +124,7 @@
125125 $res = $db->select( $tablename, array( 'value' ), array( 'propname' => $property->getDBkey() ),
126126 'SMW::getPropertyValues', $this->getSQLOptions( $requestoptions, 'value' ) + array( 'DISTINCT' ) );
127127 $result = array();
128 - while ( $row = $db->fetchObject( $res ) ) {
 128+ foreach ( $res as $row ) {
129129 $dv = SMWDataValueFactory::newPropertyObjectValue( $property );
130130 if ( $outputformat != '' ) $dv->setOutputFormat( $outputformat );
131131 $dv->setDBkeys( ( $tablename == 'smwsimple_special' ) ? array( $row->value ) : unserialize( $row->value ) );
@@ -162,7 +162,7 @@
163163 $where . $this->getSQLConditions( $requestoptions, 'p.page_title', 'p.page_title' ),
164164 'SMW::getPropertySubjects',
165165 $this->getSQLOptions( $requestoptions, 'p.page_title' ) + array( 'DISTINCT' ) );
166 - while ( $row = $db->fetchObject( $res ) ) {
 166+ foreach ( $res as $row ) {
167167 $result[] = SMWWikiPageValue::makePage( $row->title, $row->namespace, $row->title );
168168 }
169169 $db->freeResult( $res );
@@ -201,7 +201,7 @@
202202 $res = $db->select( $tablename, 'DISTINCT propname',
203203 'pageid=' . $db->addQuotes($sid) . $this->getSQLConditions( $suboptions, 'propname', 'propname' ),
204204 'SMW::getProperties', $this->getSQLOptions( $suboptions, 'propname' ) );
205 - while ( $row = $db->fetchObject( $res ) ) {
 205+ foreach ( $res as $row ) {
206206 $result[] = new SMWDIProperty( $row->propname );
207207 }
208208 $db->freeResult( $res );
@@ -241,7 +241,7 @@
242242 $res = $db->select( $tablename, 'DISTINCT propname', // select sortkey since it might be used in ordering (needed by Postgres)
243243 $where . $this->getSQLConditions( $suboptions, 'propname', 'propname' ),
244244 'SMW::getInProperties', $this->getSQLOptions( $suboptions, 'propname' ) );
245 - while ( $row = $db->fetchObject( $res ) ) {
 245+ foreach ( $res as $row ) {
246246 $result[] = new SMWDIProperty( $row->propname );
247247 }
248248 $db->freeResult( $res );
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php
@@ -353,7 +353,7 @@
354354 ( $usedistinct ? $this->getSQLOptions( $requestoptions, $valuecolumn ) + array( 'DISTINCT' ) :
355355 $this->getSQLOptions( $requestoptions, $valuecolumn ) ) );
356356
357 - while ( $row = $db->fetchObject( $res ) ) {
 357+ foreach ( $res as $row ) {
358358 if ( !$issubject ) {
359359 $propertyname = 'fixed'; // irrelevant, but use this to check if the data is good
360360 } elseif ( !$proptable->fixedproperty ) { // use joined or predefined property name
@@ -474,7 +474,7 @@
475475 'SMW::getPropertySubjects',
476476 $this->getSQLOptions( $requestoptions, 'smw_sortkey' ) );
477477
478 - while ( $row = $db->fetchObject( $res ) ) {
 478+ foreach ( $res as $row ) {
479479 try {
480480 $result[] = new SMWDIWikiPage( $row->title, $row->namespace, '' );
481481 } catch ( SMWDataItemException $e ) {
@@ -618,7 +618,7 @@
619619 $where . $this->getSQLConditions( $suboptions, 'smw_sortkey', 'smw_sortkey' ),
620620 'SMW::getProperties', $this->getSQLOptions( $suboptions, 'smw_sortkey' ) );
621621
622 - while ( $row = $db->fetchObject( $res ) ) {
 622+ foreach ( $res as $row ) {
623623 $result[] = new SMWDIProperty( $row->smw_title );
624624 }
625625 } else { // just check if subject occurs in table
@@ -684,7 +684,7 @@
685685 $where . $this->getSQLConditions( $suboptions, 'smw_sortkey', 'smw_sortkey', $where != '' ),
686686 'SMW::getInProperties', $this->getSQLOptions( $suboptions, 'smw_sortkey' ) );
687687
688 - while ( $row = $db->fetchObject( $res ) ) {
 688+ foreach ( $res as $row ) {
689689 $result[] = new SMWDIProperty( $row->smw_title );
690690 }
691691 } else {
@@ -1018,7 +1018,7 @@
10191019 $res = $db->query( $query, 'SMW::getPropertySubjects' );
10201020 $result = array();
10211021
1022 - while ( $row = $db->fetchObject( $res ) ) {
 1022+ foreach ( $res as $row ) {
10231023 $result[] = array( new SMWDIProperty( $row->smw_title ), $row->count );
10241024 }
10251025
@@ -1098,7 +1098,7 @@
10991099
11001100 $result = array();
11011101
1102 - while ( $row = $db->fetchObject( $res ) ) {
 1102+ foreach ( $res as $row ) {
11031103 $result[] = new SMWDIProperty( $row->title );
11041104 }
11051105
@@ -1140,7 +1140,7 @@
11411141 'smw_title, COUNT(*) as count', 'smw_id > 50 AND page_id IS NULL GROUP BY smw_title',
11421142 'SMW::getWantedPropertiesSpecial', $options );
11431143
1144 - while ( $row = $db->fetchObject( $res ) ) {
 1144+ foreach ( $res as $row ) {
11451145 $result[] = array( new SMWDIProperty( $row->smw_title ), $row->count );
11461146 }
11471147 }
@@ -2278,7 +2278,7 @@
22792279 $res = $db->select( 'smw_ids', 'smw_id', array( 'smw_title' => '', 'smw_namespace' => $id, 'smw_iw' => SMW_SQL2_SMWIW ), "$fname::selectBnodes" );
22802280
22812281 // ... and delete them as well
2282 - while ( $row = $db->fetchObject( $res ) ) {
 2282+ foreach ( $res as $row ) {
22832283 foreach ( self::getPropertyTables() as $proptable ) {
22842284 if ( $proptable->idsubject ) {
22852285 $db->delete( $proptable->name, array( 's_id' => $row->smw_id ), "$fname::deleteBnodes" );
@@ -2357,7 +2357,7 @@
23582358 if ( ( $subject_ns == SMW_NS_PROPERTY ) && ( $proptable->fixedproperty == false ) ) {
23592359 $res = $db->select( $from, $select, array( 'p_id' => $old_tid ), $fname );
23602360
2361 - while ( $row = $db->fetchObject( $res ) ) {
 2361+ foreach ( $res as $row ) {
23622362 $jobs[] = new SMWUpdateJob( Title::makeTitle( $row->namespace, $row->title ) );
23632363 }
23642364
@@ -2368,7 +2368,7 @@
23692369 if ( $type == 'p' ) {
23702370 $res = $db->select( $from, $select, array( $fieldname => $old_tid ), $fname );
23712371
2372 - while ( $row = $db->fetchObject( $res ) ) {
 2372+ foreach ( $res as $row ) {
23732373 $jobs[] = new SMWUpdateJob( Title::makeTitle( $row->namespace, $row->title ) );
23742374 }
23752375
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLHelpers.php
@@ -193,7 +193,7 @@
194194 $curfields = array();
195195 $result = array();
196196
197 - while ( $row = $db->fetchObject( $res ) ) {
 197+ foreach ( $res as $row ) {
198198 $type = strtoupper( $row->Type );
199199
200200 if ( $wgDBtype == 'postgres' ) { // postgresql
@@ -335,10 +335,8 @@
336336 if ( !$res ) {
337337 return false;
338338 }
339 -
340 - $indexes = array();
341 -
342 - while ( $row = $db->fetchObject( $res ) ) {
 339+
 340+ foreach ( $res as $row ) {
343341 // Remove the unneeded indexes, let indexes alone that already exist in the correct fashion.
344342 if ( array_key_exists( $row->indexcolumns, $columns ) ) {
345343 $columns[$row->indexcolumns] = false;
@@ -372,7 +370,7 @@
373371
374372 $indexes = array();
375373
376 - while ( $row = $db->fetchObject( $res ) ) {
 374+ foreach ( $res as $row ) {
377375 if ( !array_key_exists( $row->Key_name, $indexes ) ) {
378376 $indexes[$row->Key_name] = array();
379377 }

Status & tagging log