Skip to content

add reset on cache#319

Closed
fayland wants to merge 1 commit intoj4mie:developfrom
fayland:develop
Closed

add reset on cache#319
fayland wants to merge 1 commit intoj4mie:developfrom
fayland:develop

Conversation

@fayland
Copy link
Copy Markdown
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
Copy Markdown
Collaborator

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

@fayland
Copy link
Copy Markdown
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
Copy Markdown
Collaborator

treffynnon commented Mar 22, 2017 via email

@fayland
Copy link
Copy Markdown
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
Copy Markdown
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.

2 participants