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

Phalcon\Http\Response\Cookies->send() cause "The argument is not initialized or iterable" #12978

Closed
Zaporozhec7 opened this issue Jul 23, 2017 · 1 comment
Assignees
Labels
bug A bug report status: low Low
Milestone

Comments

@Zaporozhec7
Copy link

I try use Phalcon\Http\Response\Cookies, separate from Phalcon\Http\Response. In my app "Cookies" object can contain cookie, or not. And i do not have way to check, is there exists at least one cookie in it, or not, before try to send it, because class do not provide method for this.
So if there are was not added at least one cookie, on calling send() method appear exception "The argument is not initialized or iterable".
I think that because _cookies variable in class defined without value and stay null if there are no cookie set (if i understand Zephir right). And we try to iterate through it in send() method when _cookies is null

There are few ways to fix that:

  1. Make protected _cookies = []; instead protected _cookies;
  2. Check is _cookies not empty/iterable before try iterate through it
  3. Provide for Phalcon\Http\Response\Cookies class method that allow to check, is there are added cookie (something about isEmpty())

Expected behavior

When there are no cookie set, do nothing

How to reproduce

(new Phalcon\Http\Response\Cookies())->send();

Details

  • Phalcon version: 3.1.2
  • PHP Version: 7.1.4
@sergeyklay sergeyklay self-assigned this Jul 23, 2017
@sergeyklay sergeyklay added this to the 3.2.x milestone Jul 24, 2017
sergeyklay added a commit that referenced this issue Sep 2, 2017
Internal cookies property is now always an array (fixes #12978)
@sergeyklay
Copy link
Contributor

Fixed in the 3.2.x branch. Feel free to open a new issue if the problem appears again. Thank you for contributing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug report status: low Low
Projects
None yet
Development

No branches or pull requests

3 participants