Skip to content

Commit

Permalink
fix: remove session from Validation
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Aug 17, 2022
1 parent e6f167f commit 282789b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 19 deletions.
5 changes: 0 additions & 5 deletions phpstan-baseline.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -650,11 +650,6 @@ parameters:
count: 1
path: system/Throttle/Throttler.php

-
message: "#^Property CodeIgniter\\\\Validation\\\\Validation\\:\\:\\$errors \\(array\\) on left side of \\?\\? is not nullable\\.$#"
count: 1
path: system/Validation/Validation.php

-
message: "#^Variable \\$error on left side of \\?\\? always exists and is always null\\.$#"
count: 1
Expand Down
15 changes: 1 addition & 14 deletions system/Validation/Validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,6 @@ public function __construct($config, RendererInterface $view)
*/
public function run(?array $data = null, ?string $group = null, ?string $dbGroup = null): bool
{
// If there are still validation errors for redirect_with_input request, remove them.
// See `getErrors()` method.
if (isset($_SESSION, $_SESSION['_ci_validation_errors'])) {
unset($_SESSION['_ci_validation_errors']);
}

$data ??= $this->data;

// i.e. is_unique
Expand Down Expand Up @@ -681,14 +675,7 @@ public function getError(?string $field = null): string
*/
public function getErrors(): array
{
// If we already have errors, we'll use those.
// If we don't, check the session to see if any were
// passed along from a redirect_with_input request.
if (empty($this->errors) && ! is_cli() && isset($_SESSION, $_SESSION['_ci_validation_errors'])) {
$this->errors = unserialize($_SESSION['_ci_validation_errors']);
}

return $this->errors ?? [];
return $this->errors;
}

/**
Expand Down

0 comments on commit 282789b

Please sign in to comment.