Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cast arrays into scalar values safely.
strval and intval throw errors when they receive arrays. Convert string/bool values into ''/false. Integers and floats cast into 1 as that's what PHP would normally do. Refs #6083
- Loading branch information
Showing
6 changed files
with
47 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7468434
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Boo! You broke my plugin, again!
7468434
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mine, too :P But already before this due to the blind appliance of the string methods.
At least now we know that we must use a custom Type class.
7468434
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems this change breaks the JsonType example from the docs, is there a proposed fix for that?
Thanks,
7468434
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the docs there are going to be updated, it would be nice to put a mention in of
Type::marshal()
too.7468434
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@davidyell @dereuromark What broke?
7468434
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@robertscherer I can update the jsonType to have a marshal method.
7468434
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me it was in my
beforeSave()
method, the entity which was passed in should have contained a file upload array, but instead was blank.I fixed it like this, davidyell/CakePHP-Proffer@d72b88c
Which is also why I thought it was worth mentioning
marshal()
in the docs.7468434
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@markstory If a POSTed field does not have a corresponding database field it will be left untouched right? Edit: Or rather the entity property does not have a corresponding db field.
7468434
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@markstory I have fixed the issue by adding the marshal method like this to JsonType:
7468434
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ADmad Yes, fields not in the schema do not get marshalled by the type classes.