Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRITICAL when $_SESSION is null / Argument 2 passed to dot_array_search() must be [] #2450

Merged
merged 1 commit into from
Dec 24, 2019

Conversation

nowackipawel
Copy link
Contributor

newest version.

CRITICAL - 2019-12-10 19:17:06 --> Argument 2 passed to dot_array_search() must be of the type array, null given, called in /home/zdamy/site/system/Session/Session.php on line 500
#0 /home/zdamy/site/system/Session/Session.php(500): dot_array_search('ausItem', NULL)
#1 /home/zdamy/site/system/Common.php(347): CodeIgniter\Session\Session->get('ausItem')
#2 /home/zdamy/site/app/Models/AdminUserModel.php(87): session('ausItem')

BTW/ I am not sure if that method should not look like:

public function get(string $key = null)
	{
		if (! empty($key))
		{
                        if(! is_null($value = dot_array_search($key, $_SESSION??[])))
                        {
                             return $value;
                         }
                         return null;
		}
		elseif (empty($_SESSION))
		{
			return [];
		}

		$userdata = [];
		$_exclude = array_merge(
			['__ci_vars'], $this->getFlashKeys(), $this->getTempKeys()
		);

		$keys = array_keys($_SESSION);
		foreach ($keys as $key)
		{
			if (! in_array($key, $_exclude, true))
			{
				$userdata[$key] = $_SESSION[$key];
			}
		}

		return $userdata;
	}

Each pull request should address a single issue and have a meaningful title.

Description
Explain what you have changed, and why.

Checklist:

  • Securely signed commits
  • Component(s) with PHPdocs
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

---------Remove from here down in your description----------

Notes

  • Pull requests must be in English
  • If the PR solves an issue, reference it with a suitable verb and the issue number
    (e.g. fixes 12345)
  • Unsolicited pull requests will be considered, but there is no guarantee of acceptance
  • Pull requests should be from a feature branch in the contributor's fork of the repository
    to the develop branch of the project repository

newest version.

CRITICAL - 2019-12-10 19:17:06 --> Argument 2 passed to dot_array_search() must be of the type array, null given, called in /home/zdamy/site/system/Session/Session.php on line 500
#0 /home/zdamy/site/system/Session/Session.php(500): dot_array_search('ausItem', NULL)
codeigniter4#1 /home/zdamy/site/system/Common.php(347): CodeIgniter\Session\Session->get('ausItem')
codeigniter4#2 /home/zdamy/site/app/Models/AdminUserModel.php(87): session('ausItem')



BTW/ I am not sure if that method should not look like:

```
public function get(string $key = null)
	{
		if (! empty($key))
		{
                        if(! is_null($value = dot_array_search($key, $_SESSION??[])))
                        {
                             return $value;
                         }
                         return null;
		}
		elseif (empty($_SESSION))
		{
			return [];
		}

		$userdata = [];
		$_exclude = array_merge(
			['__ci_vars'], $this->getFlashKeys(), $this->getTempKeys()
		);

		$keys = array_keys($_SESSION);
		foreach ($keys as $key)
		{
			if (! in_array($key, $_exclude, true))
			{
				$userdata[$key] = $_SESSION[$key];
			}
		}

		return $userdata;
	}
```
@MGatner MGatner merged commit 06d7e2a into codeigniter4:develop Dec 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants