diff mbox

Terminates execution of the script if aurweb config file not found

Message ID 20180316201703.1592-1-nodivbyzero@gmail.com
State Accepted, archived
Headers show

Commit Message

Nodiv Byzero March 16, 2018, 8:17 p.m. UTC
---
 web/lib/confparser.inc.php | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Nodiv Byzero March 17, 2018, 4:28 a.m. UTC | #1
I spent 5 minutes to figure out why fresh aurweb install did not work
for me. Because I missed aurweb/config file.
I've added termination just in case there is not file.

On Fri, Mar 16, 2018 at 8:17 PM, nodivbyzero <nodivbyzero@gmail.com> wrote:
> ---
>  web/lib/confparser.inc.php | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/web/lib/confparser.inc.php b/web/lib/confparser.inc.php
> index e7128be..499481d 100644
> --- a/web/lib/confparser.inc.php
> +++ b/web/lib/confparser.inc.php
> @@ -8,7 +8,11 @@ function config_load() {
>                 if (!$path) {
>                         $path = "/etc/aurweb/config";
>                 }
> -               $AUR_CONFIG = parse_ini_file($path, true, INI_SCANNER_RAW);
> +               if (file_exists($path)) {
> +                       $AUR_CONFIG = parse_ini_file($path, true, INI_SCANNER_RAW);
> +               } else {
> +                       die("aurweb config file not found");
> +               }
>         }
>  }
>
> --
> 2.16.1
>
Eli Schwartz March 18, 2018, 1:31 a.m. UTC | #2
On 03/16/2018 04:17 PM, nodivbyzero wrote:
> ---
>  web/lib/confparser.inc.php | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/web/lib/confparser.inc.php b/web/lib/confparser.inc.php
> index e7128be..499481d 100644
> --- a/web/lib/confparser.inc.php
> +++ b/web/lib/confparser.inc.php
> @@ -8,7 +8,11 @@ function config_load() {
>  		if (!$path) {
>  			$path = "/etc/aurweb/config";
>  		}
> -		$AUR_CONFIG = parse_ini_file($path, true, INI_SCANNER_RAW);
> +		if (file_exists($path)) {
> +			$AUR_CONFIG = parse_ini_file($path, true, INI_SCANNER_RAW);
> +		} else {
> +			die("aurweb config file not found");
> +		}
>  	}
>  }

Very minor nit. The commit message should probably be "Terminate" rather
than "Terminates"
Lukas Fleischer March 20, 2018, 6:24 p.m. UTC | #3
On Fri, 16 Mar 2018 at 21:17:03, nodivbyzero wrote:
> ---
>  web/lib/confparser.inc.php | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> [...]

Merged with a slightly amended commit message; thanks!
diff mbox

Patch

diff --git a/web/lib/confparser.inc.php b/web/lib/confparser.inc.php
index e7128be..499481d 100644
--- a/web/lib/confparser.inc.php
+++ b/web/lib/confparser.inc.php
@@ -8,7 +8,11 @@  function config_load() {
 		if (!$path) {
 			$path = "/etc/aurweb/config";
 		}
-		$AUR_CONFIG = parse_ini_file($path, true, INI_SCANNER_RAW);
+		if (file_exists($path)) {
+			$AUR_CONFIG = parse_ini_file($path, true, INI_SCANNER_RAW);
+		} else {
+			die("aurweb config file not found");
+		}
 	}
 }