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\Tag::resetInput() is not work #12099

Closed
Studentsov opened this issue Aug 5, 2016 · 14 comments
Closed

Phalcon\Tag::resetInput() is not work #12099

Studentsov opened this issue Aug 5, 2016 · 14 comments
Assignees
Labels
bug A bug report status: medium Medium
Milestone

Comments

@Studentsov
Copy link
Contributor

Studentsov commented Aug 5, 2016

Code:

$_POST = ['a' => '1', 'b' => '2'];
\Phalcon\Tag::resetInput();
var_dump($_POST);

output:
array(2) { ["a"]=> string(1) "1" ["b"]=> string(1) "2" }

Phalcon 3.0.0
OS Windows 10, PHP 7.0.8 x64
OS CentOS 7, PHP 7.0.9 x64

This problem breaks clean forms.
I found an old message: http://stackoverflow.com/questions/37365130/how-to-clear-phalcon-form-element-values, so I think the problem is not new.

@Studentsov Studentsov changed the title Phalcon\Tag::resetInput() is not work in Phalcon 3.0.0 Phalcon\Tag::resetInput() is not work Aug 5, 2016
@sergeyklay sergeyklay modified the milestones: 3.0.x, 3.0.2 Aug 10, 2016
@sergeyklay
Copy link
Contributor

sergeyklay commented Oct 1, 2016

@Studentsov
Why did you decide that the Phalcon\Tag::resetInput should reset $_POST? Could you please explain a bit more?

As correctly noted @SidRoberts in #12227 the Phalcon\Tag::resetInput shouldn't reset $_POST. It should only reset parameters within the Phalcon\Tag object.

I agree that we have variances in the documentation about this method, and it was used in an unsuccessful attempt to clear $_POST.

But I'm really not sure that we need a method to do $_POST = [];

To clear the form you should use Phalcon\Forms\Form::clear. It clears every element in the form to its default value. I'll check Phalcon\Forms\Form::clear ASAP, but anyway this is a different issue, not related with cleaning $_POST through Phalcon\Tag::resetInput.

@sergeyklay sergeyklay added not a bug Reported issue is not a bug and removed Bug - Medium labels Oct 1, 2016
@Studentsov
Copy link
Contributor Author

Studentsov commented Oct 1, 2016

Implementation of the Phalcon\Forms\Form::clear depends on the state of the Phalcon\Tag

@Jurigag
Copy link
Contributor

Jurigag commented Oct 1, 2016

@Studentsov
Copy link
Contributor Author

@Jurigag
Copy link
Contributor

Jurigag commented Oct 1, 2016

So what ? Still it shouldn't reset $_POST. The values in form are not got from $_POST for displaying.

Also this method isn't cleaning $_POST https://github.com/phalcon/cphalcon/blob/master/phalcon/tag.zep#L258

@sergeyklay
Copy link
Contributor

@Studentsov But Phalcon\Forms\Element::clear not doing anything with $_POST

@Studentsov
Copy link
Contributor Author

Studentsov commented Oct 1, 2016

@Jurigag
Copy link
Contributor

Jurigag commented Oct 1, 2016

@niden
Copy link
Member

niden commented Oct 1, 2016

@sergeyklay and I had a discussion and this is how this must work:

  • $_POST or $_GET must not be manipulated by the framework
  • Phalcon\Tag::resetInput() must clear only the input of the Phalcon\Tag object and not the $_POST
  • Phalcon\Forms\Element::clear() must clear only the form elements and not the $_POST

@Jurigag
Copy link
Contributor

Jurigag commented Oct 1, 2016

So also this 333 line from tag.zep can't get value form $_POST. Or Form shouldn't use Tag::getValue

@Studentsov
Copy link
Contributor Author

I'm glad such a rapid discussion of architecture, but I just have to clear the form :D
I think you can change the title of issue

@sergeyklay
Copy link
Contributor

@Studentsov I'll implement clearing forms without clearing $_POST

@sergeyklay sergeyklay added Bug - Medium and removed not a bug Reported issue is not a bug labels Oct 1, 2016
@sergeyklay
Copy link
Contributor

@Studentsov Could you please take a look at #12280? In general this is what you need. Right?

@sergeyklay sergeyklay self-assigned this Oct 2, 2016
@sergeyklay
Copy link
Contributor

Fixed in 3.0.x branch.
Could you please check 3.0.x branch?

git clone git@github.com:phalcon/cphalcon.git
cd cphalcon
git checkout 3.0.x

zephir fullclean
zephir build

@niden niden added bug A bug report status: medium Medium labels Dec 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug report status: medium Medium
Projects
None yet
Development

No branches or pull requests

4 participants