diff --git a/system/Validation/Validation.php b/system/Validation/Validation.php index 2a8b361b89c9..2ffaf5d41167 100644 --- a/system/Validation/Validation.php +++ b/system/Validation/Validation.php @@ -1,5 +1,4 @@ $rule($value, $error) - : $set->$rule($value, $param, $data, $error); + $passed = $param === false ? $set->$rule($value, $error) : $set->$rule($value, $param, $data, $error); break; } @@ -291,8 +290,7 @@ protected function processRules(string $field, string $label = null, $value, $ru // Set the error message if we didn't survive. if ($passed === false) { - $this->errors[$field] = is_null($error) ? $this->getErrorMessage($rule, $field, $label, $param) - : $error; + $this->errors[$field] = is_null($error) ? $this->getErrorMessage($rule, $field, $label, $param) : $error; return false; } @@ -493,7 +491,7 @@ public function listErrors(string $template = 'list'): string } return $this->view->setVar('errors', $this->getErrors()) - ->render($this->config->templates[$template]); + ->render($this->config->templates[$template]); } //-------------------------------------------------------------------- @@ -519,7 +517,7 @@ public function showError(string $field, string $template = 'single'): string } return $this->view->setVar('error', $this->getError($field)) - ->render($this->config->templates[$template]); + ->render($this->config->templates[$template]); } //-------------------------------------------------------------------- @@ -648,13 +646,7 @@ public function getErrors(): array // passed along from a redirect_with_input request. if (empty($this->errors) && ! is_cli()) { - // Start up the session if it's not already - if (! isset($_SESSION)) - { - session(); - } - - if ($errors = session('_ci_validation_errors')) + if (isset($_SESSION) && session('_ci_validation_errors')) { $this->errors = unserialize($errors); } @@ -724,15 +716,15 @@ protected function splitRules(string $rules): array { $non_escape_bracket = '((?