mythinking / doophp

Automatically exported from code.google.com/p/doophp
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

DooSmartModel incorrectly caches prepared SQL so executing with new params selects old data #52

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. find a smart model using where and param options
2. find again with same where and different param

What is the expected output? What do you see instead?
Expected: new param gets new result
Actual: new param gets old, incorrect result

What version of the product are you using?
svn head, r465

Please provide any additional information below.
See attached test app, as a diff from r465.

Original issue reported on code.google.com by towyn...@gmail.com on 30 Jul 2010 at 9:34

Attachments:

GoogleCodeExporter commented 9 years ago
The problem is in the DooSmartModel::toCacheId() function.  The cache id is 
generated by serializing the $options array, but it does this by concatenating 
every options value to a string.

The "param" option is an array, and arrays cast to strings as literally 
"Array."  So every set of different parameters will be coded to the same cache 
unit.

Fix using php's built in serialize() function, which handles multidimensional 
arrays correctly, attached as a diff from r466.

Original comment by dan.mens...@gmail.com on 2 Aug 2010 at 4:26

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks for the patch. It has been applied and commit.

Original comment by darkredz on 5 Aug 2010 at 7:58