Update flight data class to check for the array first
authorSteve Sutton <steve@gaslightmedia.com>
Wed, 1 Jun 2016 16:41:10 +0000 (12:41 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Wed, 1 Jun 2016 16:41:10 +0000 (12:41 -0400)
errors from invalid array passed to foreach

class_flight.php
style.css

index db1ec66..a7d5dd5 100644 (file)
@@ -91,17 +91,21 @@ include_once($_SERVER['DOCUMENT_ROOT'].'/wp-config.php' );
                        $this->get_arr_flight_data();
                        $this->get_dep_flight_data();
 
-                       foreach( $this->arr_data as $key=>$value )
-                       {
-                               $update_times[] = strtotime($value['msg_dtm']);
-                               if ($row['name'] == "EXPRESS AIRLINES 1, INC.") $this->arr_data[$key]['name'] = 'Delta Airlines';
-                               if ($row['airline'] == "EXPRESS AIRLINES 1, INC.") $this->arr_data[$key]['airline'] = 'Delta Airlines';
+                       if ( isset( $this->arr_data ) && is_array( $this->arr_data ) ) {
+                               foreach( $this->arr_data as $key=>$value )
+                               {
+                                       $update_times[] = strtotime($value['msg_dtm']);
+                                       if ($row['name'] == "EXPRESS AIRLINES 1, INC.") $this->arr_data[$key]['name'] = 'Delta Airlines';
+                                       if ($row['airline'] == "EXPRESS AIRLINES 1, INC.") $this->arr_data[$key]['airline'] = 'Delta Airlines';
+                               }
                        }
-                       foreach( $this->dep_data as $key=>$value)
-                       {
-                               $update_times[] = strtotime($value['msg_dtm']);
-                               if ($row['name'] == "EXPRESS AIRLINES 1, INC.") $this->dep_data[$key]['name'] = '<nobr>Delta Airlines</nobr>';
-                               if ($row['airline'] == "EXPRESS AIRLINES 1, INC.") $this->dep_data[$key]['airline'] = '<nobr>Delta Airlines</nobr>';
+                       if ( isset( $this->dep_data ) && is_array( $this->dep_data ) ) {
+                               foreach( $this->dep_data as $key=>$value)
+                               {
+                                       $update_times[] = strtotime($value['msg_dtm']);
+                                       if ($row['name'] == "EXPRESS AIRLINES 1, INC.") $this->dep_data[$key]['name'] = '<nobr>Delta Airlines</nobr>';
+                                       if ($row['airline'] == "EXPRESS AIRLINES 1, INC.") $this->dep_data[$key]['airline'] = '<nobr>Delta Airlines</nobr>';
+                               }
                        }
                        rsort($update_times);
                        // get UTC offset for current date/time
index 7c47f4f..4a9b910 100644 (file)
--- a/style.css
+++ b/style.css
@@ -3,5 +3,5 @@ Theme Name: PellstonAirport
 Author: Gaslight Media
 Author URI: http://www.gaslightmedia.com
 Description: A theme for PellstonAirport
-Version: 1.0.2
+Version: 1.0.3
 */