From 47cdf9494d79afb26e63ebbeae9538755e20ae99 Mon Sep 17 00:00:00 2001 From: Ken Soh Date: Fri, 25 Oct 2019 19:47:13 +0800 Subject: [PATCH] #597 - PHP warning fix for macOS Catalina (#600) for details, see https://github.com/kelaberetiv/TagUI/issues/597 --- src/tagui | 2 +- src/tagui.cmd | 2 +- src/tagui_parse.php | 22 +++++++++++----------- src/tagui_report.php | 2 +- src/translate.php | 2 +- src/transpose.php | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/tagui b/src/tagui index 775dd8d4..162fba86 100755 --- a/src/tagui +++ b/src/tagui @@ -6,7 +6,7 @@ chrome_command="google-chrome" if [ -z "$1" ] then -echo "tagui v5.8: use following options and this syntax to run - ./tagui flow_filename option(s)" +echo "tagui v5.9: use following options and this syntax to run - ./tagui flow_filename option(s)" echo echo "chrome - run on visible Chrome web browser instead of invisible PhantomJS (first install Chrome)" echo "headless - run on invisible Chrome web browser instead of default PhantomJS (first install Chrome)" diff --git a/src/tagui.cmd b/src/tagui.cmd index 13f92fe0..e3d10c60 100644 --- a/src/tagui.cmd +++ b/src/tagui.cmd @@ -8,7 +8,7 @@ rem enable windows for loop advanced flow control setlocal enableextensions enabledelayedexpansion if "%~1"=="" ( -echo tagui v5.8: use following options and this syntax to run - tagui flow_filename option^(s^) +echo tagui v5.9: use following options and this syntax to run - tagui flow_filename option^(s^) echo. echo chrome - run on visible Chrome web browser instead of invisible PhantomJS ^(first install Chrome^) echo headless - run on invisible Chrome web browser instead of default PhantomJS ^(first install Chrome^) diff --git a/src/tagui_parse.php b/src/tagui_parse.php index 4d93e75a..be90d29a 100755 --- a/src/tagui_parse.php +++ b/src/tagui_parse.php @@ -25,28 +25,28 @@ $repo_count = 0; if (file_exists(getenv('custom_csv_file'))) { // load datatable or legacy datatable / repository $repo_file = fopen(getenv('custom_csv_file'),'r') or die("ERROR - cannot open " . getenv('custom_csv_file') . "\n"); while (!feof($repo_file)) {$repo_data[$repo_count] = fgetcsv($repo_file); -if (count($repo_data[$repo_count]) == 0) die("ERROR - empty row found in " . getenv('custom_csv_file') . "\n"); +if (@count($repo_data[$repo_count]) == 0) die("ERROR - empty row found in " . getenv('custom_csv_file') . "\n"); $repo_count++;} fclose($repo_file); $repo_count-=1; //-1 for header, for EOF need to check flexibly using below line -if (count($repo_data[$repo_count]) == 1) $repo_count-=1;} //-1 for EOF (Windows files don't end with newline character) +if (@count($repo_data[$repo_count]) == 1) $repo_count-=1;} //-1 for EOF (Windows files don't end with newline character) $local_repo_location = str_replace("\\","/",dirname($script)) . '/tagui_local.csv'; if (file_exists($local_repo_location)) { // load local repository file if it exists for objects and keywords $local_repo_file = fopen($local_repo_location,'r') or die("ERROR - cannot open " . 'tagui_local.csv' . "\n"); if ($repo_count != 0) $repo_count++; fgetcsv($local_repo_file); // +1 if array has data, discard header record while (!feof($local_repo_file)) {$repo_data[$repo_count] = fgetcsv($local_repo_file); -if (count($repo_data[$repo_count]) == 0) die("ERROR - empty row found in " . 'tagui_local.csv' . "\n"); -if (count($repo_data[$repo_count]) != 1) // pad the empty columns when local repository is used with datatable -{$repo_data[$repo_count] = array_pad($repo_data[$repo_count], count($repo_data[0]), $repo_data[$repo_count][1]);} -$repo_count++;} fclose($local_repo_file); $repo_count-=1; if (count($repo_data[$repo_count]) == 1) $repo_count-=1;} +if (@count($repo_data[$repo_count]) == 0) die("ERROR - empty row found in " . 'tagui_local.csv' . "\n"); +if (@count($repo_data[$repo_count]) != 1) // pad the empty columns when local repository is used with datatable +{$repo_data[$repo_count] = array_pad($repo_data[$repo_count], @count($repo_data[0]), $repo_data[$repo_count][1]);} +$repo_count++;} fclose($local_repo_file); $repo_count-=1; if (@count($repo_data[$repo_count]) == 1) $repo_count-=1;} if (file_exists('tagui_global.csv')) { // load global repository file if it exists for objects and keywords $global_repo_file = fopen('tagui_global.csv','r') or die("ERROR - cannot open " . 'tagui_global.csv' . "\n"); if ($repo_count != 0) $repo_count++; fgetcsv($global_repo_file); // +1 if array has data, discard header record while (!feof($global_repo_file)) {$repo_data[$repo_count] = fgetcsv($global_repo_file); -if (count($repo_data[$repo_count]) == 0) die("ERROR - empty row found in " . 'tagui_global.csv' . "\n"); -if (count($repo_data[$repo_count]) != 1) // pad the empty columns when global repository is used with datatable -{$repo_data[$repo_count] = array_pad($repo_data[$repo_count], count($repo_data[0]), $repo_data[$repo_count][1]);} -$repo_count++;} fclose($global_repo_file); $repo_count-=1; if (count($repo_data[$repo_count]) == 1) $repo_count-=1;} +if (@count($repo_data[$repo_count]) == 0) die("ERROR - empty row found in " . 'tagui_global.csv' . "\n"); +if (@count($repo_data[$repo_count]) != 1) // pad the empty columns when global repository is used with datatable +{$repo_data[$repo_count] = array_pad($repo_data[$repo_count], @count($repo_data[0]), $repo_data[$repo_count][1]);} +$repo_count++;} fclose($global_repo_file); $repo_count-=1; if (@count($repo_data[$repo_count]) == 1) $repo_count-=1;} $tagui_web_browser = "this"; // set the web browser to be used base on tagui_web_browser environment variable if ((getenv('tagui_web_browser')=='headless') or (getenv('tagui_web_browser')=='chrome')) $tagui_web_browser = 'chrome'; @@ -1087,7 +1087,7 @@ function parse_condition($logic) { // natural language handling for conditions $token = explode(" ",$logic); // split into tokens for loop in natural language, eg - for cupcake from 1 to 4 if (strpos($raw_logic,"{")!==false) // show error to put { to next line for parsing as { step echo "ERROR - " . current_line() . " put { to next line - " . $raw_logic . "\n"; -else if (count($token) != 6) echo "ERROR - " . current_line() . " invalid for loop - " . $raw_logic . "\n"; +else if (@count($token) != 6) echo "ERROR - " . current_line() . " invalid for loop - " . $raw_logic . "\n"; else $logic = $token[0]." (".$token[1]."=".$token[3]."; ".$token[1]."<=".$token[5]."; ".$token[1]."++)";} else if ((substr($logic,0,4)=="for ") and (strpos($raw_logic,"{")!==false)) echo "ERROR - " . current_line() . " put { to next line - " . $raw_logic . "\n"; diff --git a/src/tagui_report.php b/src/tagui_report.php index ae7c6cd5..1367faa5 100644 --- a/src/tagui_report.php +++ b/src/tagui_report.php @@ -37,7 +37,7 @@ $audit_output_header = '"#","AUTOMATION FLOW","START TIME","FINISH TIME","ERROR STATUS","LOG FILE"'; if (!file_exists('tagui_report.csv')) file_put_contents('tagui_report.csv', $audit_output_header . "\r\n"); -$audit_output_count = count(file('tagui_report.csv')) - 1 + 1; // to track and increment entry # in audit file +$audit_output_count = @count(file('tagui_report.csv')) - 1 + 1; // to track and increment entry # in audit file $html_log_file = $script . '_' . $audit_output_count . '.html'; // to allow log persistence without overwriting $audit_output_line = '"' . $audit_output_count . '","' . $escaped_script . '","' . $start_timestamp . '","'; $audit_output_line .= $finish_timestamp . '","' . $error_status . '","' . $html_log_file . '"' . "\r\n"; diff --git a/src/translate.php b/src/translate.php index 32f1c820..2af280b2 100644 --- a/src/translate.php +++ b/src/translate.php @@ -48,7 +48,7 @@ $language = strtolower($language); $language_count = 0; if (file_exists('languages/' . $language . '.csv')) { $language_file = fopen('languages/' . $language . '.csv','r') or die("ERROR - cannot open " . $language . '.csv' . "\n"); while (!feof($language_file)) {$language_data[$language_count] = fgetcsv($language_file); -if (count($language_data[$language_count]) == 0) die("ERROR - empty row found in " . $language . '.csv' . "\n"); +if (@count($language_data[$language_count]) == 0) die("ERROR - empty row found in " . $language . '.csv' . "\n"); $language_count++;} fclose($language_file); $language_count-=1; // -1 for header if ($language_data[$language_count][0] == '') $language_count-=1;} // -1 for EOF else die("ERROR - missing language file " . $language . '.csv' . "\n"); diff --git a/src/transpose.php b/src/transpose.php index ba64917d..42abc7be 100644 --- a/src/transpose.php +++ b/src/transpose.php @@ -11,7 +11,7 @@ if (is_array($csv_line) && $csv_line[0] !== null) { $csv_data[] = $csv_line; } -} fclose($source_file); $csv_count = count($csv_data); +} fclose($source_file); $csv_count = @count($csv_data); // do some prep, transpose datatable and output csv file $csv_result = array(); $target_csv = str_replace("_transpose.csv",".csv",$source_csv);