File tree Expand file tree Collapse file tree 4 files changed +166
-162
lines changed
pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI Expand file tree Collapse file tree 4 files changed +166
-162
lines changed Original file line number Diff line number Diff line change @@ -1199,9 +1199,20 @@ 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+ " header('Content-Type: application/json'); \n" .
1212+ " http_response_code(503); \n" .
1213+ " echo ' $ unavailable_error_json'; \n" .
1214+ " exit(503); \n" .
1215+ "} \n" .
12051216 "echo (new $ fq_class_name())->process_request(); \n" .
12061217 "header('Referer: no-referrer'); \n" .
12071218 "session_destroy(); \n" .
Original file line number Diff line number Diff line change @@ -529,14 +529,16 @@ 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+ " http_response_code(503); \n" .
537+ " echo '<h1>Service Unavailable</h1>'; \n" .
538+ " echo 'This resource is either not installed or is currently updating. Please try again later.'; \n" .
539+ " exit(); \n" .
540+ "} \n" .
541+ "(new $ fq_class_name())->print_form(); \n" ;
540542
541543 # Assign the absolute path to the file. Assume index.php filename if not specified.
542544 $ filename = "/usr/local/www/ $ this ->url " ;
@@ -548,7 +550,6 @@ class Form {
548550 if (is_file ($ filename )) {
549551 return true ;
550552 }
551-
552553 return false ;
553554 }
554555}
Original file line number Diff line number Diff line change @@ -31,8 +31,10 @@ class SystemRESTAPIUpdatesForm extends Form {
3131
3232 public function on_save (string $ success_banner_msg = '' ): void {
3333 parent ::on_save (
34- success_banner_msg: 'The requested version is being installed in the background. Check this page again ' .
35- 'later to see the status. ' ,
34+ success_banner_msg: 'The requested version is being installed in the background. During the update, the ' .
35+ "REST API may be intermittently unavailable. Attempts to access the REST API's endpoints and web " .
36+ 'pages during the update may result in errors until it completes. Check this page again later to see ' .
37+ 'the status. ' ,
3638 );
3739 }
3840}
You can’t perform that action at this time.
0 commit comments