Open kakduman opened 1 year ago
In components/modules/pterodactyl/lib/pterodactyl_rule.php replace parseEggVariable() with the following
/**
* Parses an egg variable from Pterodactyl and returns a Blesta input validation rule array
*
* @param string $eggVariable The egg variabe from Pteerodactyl to create rules for and from
* @return array A list of Blesta rules parsed from the Pterodactyl rule string
*/
public function parseEggVariable($eggVariable)
{
// Get the name of the field being validated
$fieldName = $eggVariable->attributes->name;
// Parse rule string for regexes and remove them to simplify parsing
$ruleString = $eggVariable->attributes->rules;
// Match the regex strings and store them in an array
$regexRuleStrings = [];
preg_match_all("/regex\\:(\\/.*?\\/)/i", $ruleString, $regexRuleStrings);
// Remove the regex stings and replace them with {{{regex}}}
$regexFilteredRuleString = str_replace($regexRuleStrings[1] ?? [], '{{{regex}}}', $ruleString);
// Get a the list of OR separated validation rules
$ruleStrings = explode('|', $regexFilteredRuleString);
// Parse rules from the string
$rules = [];
foreach ($ruleStrings as $ruleString) {
$ruleParts = explode(':', $ruleString);
$ruleName = str_replace('_', '', lcfirst(ucwords($ruleParts[0], '_')));
$ruleParameters = [];
if (isset($ruleParts[1])) {
$ruleParameters = explode(',', $ruleParts[1]);
}
// Re-add filtered regexes
if (!empty($regexRuleStrings[1])) {
foreach ($ruleParameters as &$ruleParameter) {
$ruleParameter = str_replace('{{{regex}}}', array_shift($regexRuleStrings[1]), $ruleParameter);
}
}
// Generate validation rule
if (method_exists($this, $ruleName)) {
$rules[$ruleName] = call_user_func_array(
[$this, $ruleName],
[$fieldName, $ruleParameters]
);
}
}
// Make all rules conditional on field existence
if (strpos($eggVariable->attributes->rules, 'required') === false) {
foreach ($rules as &$rule) {
$rule['if_set'] = true;
}
}
return $rules;
}
When creating a new server, proceeding to the "Review Order" step results in an HTTP Error 500. Logs show the following:
This makes it impossible to order new services on PHP 8.1. Reverting to PHP 7.4 fixes the issue. However, PHP 7.4 seems unable to provision pending services automatically, instead sending this notice to logs. The cron fails to complete and perpetually has a task lock.
I am using the latest Blesta (5.6.1) and the latest Pterodactyl module (1.8.1) running on Ubuntu 20.04.