Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
290 changes: 140 additions & 150 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -1199,9 +1199,20 @@ class Endpoint {
$nq_class_name = $this->get_class_shortname();

# Specify the PHP code to write to the Endpoints index.php file
$unavailable_error = new ServiceUnavailableError(
message: 'This resource is either not installed or is currently updating. Please try again later.',
response_id: 'ENDPOINT_UNAVAILABLE',
);
$unavailable_error_json = json_encode($unavailable_error->to_representation());
$code =
"<?php\n" .
"require_once('RESTAPI/Endpoints/$nq_class_name.inc');\n" .
"\$include = include('RESTAPI/Endpoints/$nq_class_name.inc');\n" .
"if (!\$include) {\n" .
" header('Content-Type: application/json');\n" .
" http_response_code(503);\n" .
" echo '$unavailable_error_json';\n" .
" exit(503);\n" .
"}\n" .
"echo (new $fq_class_name())->process_request();\n" .
"header('Referer: no-referrer');\n" .
"session_destroy();\n" .
Expand Down
19 changes: 10 additions & 9 deletions pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Core/Form.inc
Original file line number Diff line number Diff line change
Expand Up @@ -529,14 +529,16 @@ class Form {

# Specify the PHP code to write to the Endpoints index.php file
$code =
"<?php
require_once('RESTAPI/Forms/" .
$nq_class_name .
".inc');
require_once('guiconfig.inc');
(new " .
$fq_class_name .
'())->print_form();';
"<?php\n" .
"require_once('guiconfig.inc');\n" .
"\$include = include('RESTAPI/Forms/$nq_class_name.inc');\n" .
"if (!\$include) {\n" .
" http_response_code(503);\n" .
" echo '<h1>Service Unavailable</h1>';\n" .
" echo 'This resource is either not installed or is currently updating. Please try again later.';\n" .
" exit();\n" .
"}\n" .
"(new $fq_class_name())->print_form();\n";

# Assign the absolute path to the file. Assume index.php filename if not specified.
$filename = "/usr/local/www/$this->url";
Expand All @@ -548,7 +550,6 @@ class Form {
if (is_file($filename)) {
return true;
}

return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ class SystemRESTAPIUpdatesForm extends Form {

public function on_save(string $success_banner_msg = ''): void {
parent::on_save(
success_banner_msg: 'The requested version is being installed in the background. Check this page again ' .
'later to see the status.',
success_banner_msg: 'The requested version is being installed in the background. During the update, the ' .
"REST API may be intermittently unavailable. Attempts to access the REST API's endpoints and web " .
'pages during the update may result in errors until it completes. Check this page again later to see ' .
'the status.',
);
}
}
Loading