mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-13 08:09:41 +00:00
MVC: PortField keep options in static set. for https://github.com/opnsense/core/pull/4019
This commit is contained in:
parent
29b1489fda
commit
fe335024fb
@ -87,10 +87,15 @@ class PortField extends BaseListField
|
||||
'rfb'
|
||||
);
|
||||
|
||||
/**
|
||||
* @var array cached collected ports
|
||||
*/
|
||||
private static $internalCacheOptionList = array();
|
||||
|
||||
/**
|
||||
* @var bool enable well known ports
|
||||
*/
|
||||
private $enableWellKown = false;
|
||||
private $enableWellKnown = false;
|
||||
|
||||
/**
|
||||
* @var bool enable port ranges
|
||||
@ -102,15 +107,20 @@ class PortField extends BaseListField
|
||||
*/
|
||||
protected function actionPostLoadingEvent()
|
||||
{
|
||||
if ($this->enableWellKown) {
|
||||
foreach (array("any") + self::$wellknownservices as $wellknown) {
|
||||
$this->internalOptionList[(string)$wellknown] = $wellknown;
|
||||
// only enableWellKnown influences valid options, keep static sets per option.
|
||||
$setid = $this->enableWellKnown ? "1" : "0";
|
||||
if (empty(self::$internalCacheOptionList[$setid])) {
|
||||
self::$internalCacheOptionList[$setid] = array();
|
||||
if ($this->enableWellKnown) {
|
||||
foreach (array("any") + self::$wellknownservices as $wellknown) {
|
||||
self::$internalCacheOptionList[$setid][(string)$wellknown] = $wellknown;
|
||||
}
|
||||
}
|
||||
for ($port = 1; $port <= 65535; $port++) {
|
||||
self::$internalCacheOptionList[$setid][(string)$port] = (string)$port;
|
||||
}
|
||||
}
|
||||
|
||||
for ($port = 1; $port <= 65535; $port++) {
|
||||
$this->internalOptionList[(string)$port] = (string)$port;
|
||||
}
|
||||
$this->internalOptionList = self::$internalCacheOptionList[$setid];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -119,7 +129,7 @@ class PortField extends BaseListField
|
||||
*/
|
||||
public function setEnableWellKnown($value)
|
||||
{
|
||||
$this->enableWellKown = (strtoupper(trim($value)) == "Y");
|
||||
$this->enableWellKnown = (strtoupper(trim($value)) == "Y");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -147,7 +157,7 @@ class PortField extends BaseListField
|
||||
{
|
||||
if ($this->internalValidationMessage == null) {
|
||||
$msg = gettext('Please specify a valid port number (1-65535).');
|
||||
if ($this->enableWellKown) {
|
||||
if ($this->enableWellKnown) {
|
||||
$msg .= ' ' . sprintf(gettext('A service name is also possible (%s).'), implode(', ', self::$wellknownservices));
|
||||
}
|
||||
} else {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user