Physikerwelt has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/248691

Change subject: Update while style iterators
......................................................................

Update while style iterators

Completly remove assignments in while loops

See also T92744

Change-Id: I4bcdcc5add9b9c1d58d5a59e8fd44fba8957e5c1
---
M includes/ImportCsv.php
M includes/MathSearchTerm.php
2 files changed, 8 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MathSearch 
refs/changes/91/248691/1

diff --git a/includes/ImportCsv.php b/includes/ImportCsv.php
index 426d4e0..8241159 100644
--- a/includes/ImportCsv.php
+++ b/includes/ImportCsv.php
@@ -120,6 +120,7 @@
        /**
         * @param $csv_file
         * @return null
+        * @throws Exception
         */
        public function importFromFile( $csv_file ) {
                if ( is_null( $csv_file ) ) {
@@ -128,8 +129,13 @@
 
                $table = array();
 
-               while ( ( $line = fgetcsv( $csv_file ) ) !== false ) {
+               $line = fgetcsv( $csv_file );
+               if ( $line === null ) {
+                       throw new Exception( "Problem processing the csv file." 
);
+               }
+               while ( $line !== false ) {
                        array_push( $table, $line );
+                       $line = fgetcsv( $csv_file );
                }
                fclose( $csv_file );
 
diff --git a/includes/MathSearchTerm.php b/includes/MathSearchTerm.php
index 329ca1d..43ff8c7 100644
--- a/includes/MathSearchTerm.php
+++ b/includes/MathSearchTerm.php
@@ -92,7 +92,7 @@
                                $search->setLimitOffset( 10000 );
                                $sres = $search->searchText( $this->getExpr() );
                                if ( $sres ) {
-                                       while ( ( $tres = $sres->next() ) !== 
false ) {
+                                       foreach ( $sres as $tres ) {
                                                $revisionID = 
$tres->getTitle()->getLatestRevID();
                                                
$this->resultSet[(string)$revisionID] = $tres;
                                                $this->relevanceMap[] = 
$revisionID;

-- 
To view, visit https://gerrit.wikimedia.org/r/248691
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4bcdcc5add9b9c1d58d5a59e8fd44fba8957e5c1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MathSearch
Gerrit-Branch: master
Gerrit-Owner: Physikerwelt <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to