File tree Expand file tree Collapse file tree
pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Core Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1199,9 +1199,18 @@ class Endpoint {
11991199 $ nq_class_name = $ this ->get_class_shortname ();
12001200
12011201 # Specify the PHP code to write to the Endpoints index.php file
1202+ $ unavailable_error = new ServiceUnavailableError (
1203+ message: 'This resource is either not installed or is currently updating. Please try again later. ' ,
1204+ response_id: 'ENDPOINT_UNAVAILABLE ' ,
1205+ );
1206+ $ unavailable_error_json = json_encode ($ unavailable_error ->to_representation ());
12021207 $ code =
12031208 "<?php \n" .
1204- "require_once('RESTAPI/Endpoints/ $ nq_class_name.inc'); \n" .
1209+ "\$include = include('RESTAPI/Endpoints/ $ nq_class_name.inc'); \n" .
1210+ "if (! \$include) { \n" .
1211+ " echo ' $ unavailable_error_json'; \n" .
1212+ " exit(503); \n" .
1213+ "} \n" .
12051214 "echo (new $ fq_class_name())->process_request(); \n" .
12061215 "header('Referer: no-referrer'); \n" .
12071216 "session_destroy(); \n" .
Original file line number Diff line number Diff line change @@ -529,14 +529,15 @@ class Form {
529529
530530 # Specify the PHP code to write to the Endpoints index.php file
531531 $ code =
532- "<?php
533- require_once('RESTAPI/Forms/ " .
534- $ nq_class_name .
535- ".inc');
536- require_once('guiconfig.inc');
537- (new " .
538- $ fq_class_name .
539- '())->print_form(); ' ;
532+ "<?php \n" .
533+ "require_once('guiconfig.inc'); \n" .
534+ "\$include = include('RESTAPI/Forms/ $ nq_class_name.inc'); \n" .
535+ "if (! \$include) { \n" .
536+ " echo '<h1>Service Unavailable</h1>'; \n" .
537+ " echo 'This resource is either not installed or is currently updating. Please try again later.'; \n" .
538+ " exit(503); \n" .
539+ "} \n" .
540+ "(new $ fq_class_name())->print_form(); \n" ;
540541
541542 # Assign the absolute path to the file. Assume index.php filename if not specified.
542543 $ filename = "/usr/local/www/ $ this ->url " ;
You can’t perform that action at this time.
0 commit comments