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

add reset on cache #319

Closed
wants to merge 1 commit into from
Closed

add reset on cache #319

wants to merge 1 commit into from

Conversation

fayland
Copy link
Contributor

@fayland fayland commented Mar 22, 2017

Sorry i'm using ST3 so it removes extra space in lines.

the fix is mainly

                 if ($cached_result !== false) {
+                    // reset Idiorm after executing the query
+                    $this->_values = array();
+                    $this->_result_columns = array('*');
+                    $this->_using_default_result_columns = true;
+
                     return $cached_result;
                 }

in _run

we'll need reset the _values etc. or else we'll get

Invalid parameter number: number of bound variables does not match number of tokens

b/c I checked, the _values are just duplicated.

I'll provide a test later but from a rough glance, I think it's a bug.

Thanks

@treffynnon
Copy link
Collaborator

I don't fully understand the problem that is being solved here. Could you list out the steps to replicate?

@fayland
Copy link
Contributor Author

fayland commented Mar 22, 2017

it should have same effect why you have those lines in _run few lines later I think.

@treffynnon
Copy link
Collaborator

treffynnon commented Mar 22, 2017 via email

@fayland
Copy link
Contributor Author

fayland commented Mar 22, 2017

dummy code:

ORM::configure('logging', true);
ORM::configure('caching', true);

$rs = ORM::for_table('league')->where('class_id', 1);
$total = $rs->count();
$rows = $rs->limit(1)->find_many();

$rs = ORM::for_table('league')->where('class_id', 1);
$total = $rs->count();
$rows = $rs->limit(1)->find_many();

NOTE first 3 lines set $CACHE.

and second part first line ->count() setup ->_values
then second ->find_many() will be broken with

PHP Fatal error:  Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens' 

if you go dump the _values, you'll find the first ->count does not clear it b/c it returned from the cache.

hope it clears

Thanks

@treffynnon treffynnon added this to the 1.5.4 milestone Jan 2, 2018
treffynnon added a commit that referenced this pull request Jan 3, 2018
@treffynnon
Copy link
Collaborator

Thank you for the pull request. I have written a test and implemented it slightly differently to remove duplication, but it is now merged into develop with commit 5f220f3

@treffynnon treffynnon closed this Jan 3, 2018
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

Successfully merging this pull request may close these issues.

None yet

2 participants