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

Creating array property in SessionSection has no effect #191

Closed
thorewi opened this issue Jan 7, 2021 · 1 comment · Fixed by #192
Closed

Creating array property in SessionSection has no effect #191

thorewi opened this issue Jan 7, 2021 · 1 comment · Fixed by #192

Comments

@thorewi
Copy link

thorewi commented Jan 7, 2021

Version: 3.1.0

Bug Description

When I create sessionSection and save an array property to it with one element, it does not have any effect.

Steps To Reproduce

$cart = $this->session->getSection('cart');			
$cart->items[0] = 0;
echo $cart->items[0];

I get notice Trying to access array offset on value of type null.

Expected Behavior

To get 0

@redeyecz
Copy link
Contributor

There is a typo in Nette\Http\SessionSection, missing reference in __get


	/**
	 * Gets a variable from this session section.
	 * @return mixed
	 */
	public function &__get(string $name)
	{
		$data = &$this->getData(false); // <=== this line is missing the reference in version v3.1.0
		if ($this->warnOnUndefined && !array_key_exists($name, $data ?? [])) {
			trigger_error("The variable '$name' does not exist in session section");
		}

		return $data[$name];
	}

@dg dg closed this as completed in #192 Jan 15, 2021
dg pushed a commit that referenced this issue Jan 15, 2021
Co-authored-by: Vojtech Dolezal <vojtech.dolezalu@gmail.com>
dg pushed a commit that referenced this issue Jan 15, 2021
Co-authored-by: Vojtech Dolezal <vojtech.dolezalu@gmail.com>
dg pushed a commit that referenced this issue Jan 15, 2021
Co-authored-by: Vojtech Dolezal <vojtech.dolezalu@gmail.com>
dg pushed a commit that referenced this issue Jan 21, 2021
Co-authored-by: Vojtech Dolezal <vojtech.dolezalu@gmail.com>
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 a pull request may close this issue.

2 participants