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

Rule {} does not have an error message #180

Closed
rmsj opened this issue Apr 5, 2017 · 4 comments
Closed

Rule {} does not have an error message #180

rmsj opened this issue Apr 5, 2017 · 4 comments

Comments

@rmsj
Copy link

rmsj commented Apr 5, 2017

Gump keeps randomly raising the error on get_readable_errors.
It is just random - one second it can find the message the other cannot.

@filisko
Copy link
Collaborator

filisko commented Apr 5, 2017

Could you detail your problem please?

@lchambers
Copy link

I'm getting the same error and I'm running it on PHP 7.0.15.

I've extended GUMP into my own class and within it I call the run method and if it fails then I call the get_errors_array method to carry out my own error message processing.

It's throwing the following error within that method:

PHP Fatal error: Uncaught Exception: Rule "validate_required" does not have an error message in /vendor/wixel/gump/gump.class.php:631

I've tried to debug it myself and I can't seem to work out what's going on with it. Within the get_errors_array method there's a "foreach ($this->errors as $e)" loop and dumping the messages array up until the error is thrown, it shows the messages array just fine, but just before it throws it dumps the variable as a bool(true).

It's an odd one...

@lchambers
Copy link

lchambers commented Apr 19, 2017

Update: I finally figured out what was going on.

If you validate 1 set of data and then validate another set which is completely different, using a separately initialised GUMP object (in my case I have validation taking place across several different models), then that's when it throws the error.

It's happening due to the the language file being included using require_once, within the get_messages method - line 522. As it's already been included the first time, when the validation is run on the second validation it returns bool(true) rather than the array of messages, as I was dumping out.

If I include the method within my extended class, update the path variables to the file and then change this from "require_once" to "require" it no longer throws the error.

I hope that helps.

@filisko
Copy link
Collaborator

filisko commented Apr 28, 2017

Thank you very much @lchambers ! Fixed on commit 616ba9c.

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

No branches or pull requests

3 participants