private string $url;
+ private bool $failedValidation = false;
+
/**
* @inheritDoc
*/
if ($url && ApplicationHandler::getInstance()->isInternalURL($url)) {
$this->url = $url;
}
+
+ if (isset($_GET['failedValidation'])) {
+ $this->failedValidation = true;
+ }
}
/**
->fieldId('noCredentialsConfirm')
);
}
+
+ if ($this->failedValidation) {
+ $formField = $this->form->getNodeById('serialNo');
+ if ($formField instanceof TextFormField) {
+ $formField->addValidationError(new FormFieldValidationError(
+ 'failedValidation',
+ 'wcf.acp.firstTimeSetup.license.credentials.error.failedValidation'
+ ));
+ }
+ }
}
/**
namespace wcf\acp\page;
+use GuzzleHttp\Exception\ConnectException;
use Laminas\Diactoros\Response\RedirectResponse;
+use Psr\Http\Client\ClientExceptionInterface;
use wcf\acp\form\LicenseEditForm;
use wcf\data\package\Package;
use wcf\data\package\update\PackageUpdate;
// Cache valid license data for 2 minutes.
|| $licenseData->creationDate->getTimestamp() < (\TIME_NOW - 2 * 60)
) {
- $licenseData = $licenseApi->fetchFromRemote();
+ try {
+ $licenseData = $licenseApi->fetchFromRemote();
+ } catch (ConnectException | ClientExceptionInterface) {
+ return new RedirectResponse(
+ LinkHandler::getInstance()->getControllerLink(
+ LicenseEditForm::class,
+ [
+ 'failedValidation' => 1,
+ 'url' => LinkHandler::getInstance()->getControllerLink(LicensePage::class),
+ ],
+ ),
+ );
+ }
+
$licenseApi->updateLicenseFile($licenseData);
}
} catch (ParsingFailed $e) {