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

[BUG] Model MetaData reset method has little impact #1934

Closed
fangface opened this issue Jan 28, 2014 · 5 comments
Closed

[BUG] Model MetaData reset method has little impact #1934

fangface opened this issue Jan 28, 2014 · 5 comments

Comments

@fangface
Copy link

None of the following model metadata cache options do anything other than remove the cached data from memory when the reset() method is called. So when the meta data is reloaded it is obtained from the cache again as it was before reset() was called rather than recalculated from the db which is what I would expect to happen after calling reset().

Phalcon\Mvc\Model\MetaData\Apc
Phalcon\Mvc\Model\MetaData\Files
Phalcon\Mvc\Model\MetaData\Xcache

I am using reset() when switching between different databases when using the same model i.e. Robots on localhost and Robots on remoteHost which may have slightly different table structures.

@ghost
Copy link

ghost commented Feb 1, 2014

Fix submitted (#1952)

@ghost
Copy link

ghost commented Feb 6, 2014

Could you please check and close this bug if everything works for you?

@fangface
Copy link
Author

fangface commented Feb 6, 2014

I have downloaded and compiled the latest version of 1.3.0 and can see code in apc.c and files.c suggesting something different should happen but nothing different does happen. If I use reset() whilst using Phalcon\Mvc\Model\MetaData\Files(), for example, the files are not removed from the file system. Neither apc.c or files.c seem to clear anything out and then return the same structure.

Have I downloaded the incorrect version? phpversion('phalcon') returns 1.3.0 after compiling.

The php notice warning also still exists for #1952 still.

@ghost
Copy link

ghost commented Feb 6, 2014

php build/gen-build.php

then rebuild Phalcon.

@fangface
Copy link
Author

fangface commented Feb 7, 2014

The php notice warning #1952 is fixed.

Phalcon\Mvc\Model\MetaData\Files::reset() now works well.

Phalcon\Mvc\Model\MetaData\Apc::reset() still has an issue in that Metadata stored within Apc does not get reset unless there is some metadata already loaded into local memory. So if I try to reset Apc at the start of a script to clear out stale/incorrect metadata left over at the end of a previous iteration nothing gets cleared causing an error if the table structures are different.

if (Z_TYPE_P(meta) == IS_ARRAY) {
 // ...
}

I would also argue that all metadata cache methods need to support the 'prefix' option to allow for multi-user multi-server environments where a developer may want to cache the structure of tables on localhost but also cache the structures on remotehost at the same time but flick between the two depending on which user or host is in use. I see at least one other framework makes use of the connection dsn + username to create keys for the storage of such data to deal with this situation. Just a suggestion.

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

2 participants