Allow generating page when a candidates.csv file doesn't exist
This commit is contained in:
@@ -27,6 +27,7 @@ if (isset($options['candidates-file'])) {
|
|||||||
|
|
||||||
// Convert CSV into an array of dictionaries. Use the header as the key in the dictionary.
|
// Convert CSV into an array of dictionaries. Use the header as the key in the dictionary.
|
||||||
$candidateData = [];
|
$candidateData = [];
|
||||||
|
if (file_exists($candidatesFile)) {
|
||||||
if (($handle = fopen($candidatesFile, "r")) !== FALSE) {
|
if (($handle = fopen($candidatesFile, "r")) !== FALSE) {
|
||||||
$headers = fgetcsv($handle);
|
$headers = fgetcsv($handle);
|
||||||
while (($data = fgetcsv($handle)) !== FALSE) {
|
while (($data = fgetcsv($handle)) !== FALSE) {
|
||||||
@@ -41,9 +42,8 @@ if (($handle = fopen($candidatesFile, "r")) !== FALSE) {
|
|||||||
error_log('Error opening candidates file');
|
error_log('Error opening candidates file');
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
if (empty($candidateData)) {
|
error_log("The specified candidates.csv file does not exist, will not show any candidates for " . $councilData["shortName"] . ".");
|
||||||
error_log("Failed to load any candidates for " . $councilData['shortName']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($options['media-file'])) {
|
if (isset($options['media-file'])) {
|
||||||
|
|||||||
Reference in New Issue
Block a user