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

metadata name not present leads to exception #39

Closed
flip111 opened this issue Nov 9, 2013 · 4 comments
Closed

metadata name not present leads to exception #39

flip111 opened this issue Nov 9, 2013 · 4 comments

Comments

@flip111
Copy link
Contributor

flip111 commented Nov 9, 2013

I have a situation where an exception is thrown from this point https://github.com/schmittjoh/metadata/blob/master/src/Metadata/Cache/FileCache.php#L48 The file is ".cache.php" which leads me to conclude that the $metadata->name property was not present. In which cases can this happen? And shouldn't the library safe-guard against this ??

@flip111
Copy link
Contributor Author

flip111 commented Nov 15, 2013

Additionally .. i found this when getting an error like "Could not write new cache file to C:/inetpub/symfony/app/cache/prod/jms_diextra/metadata/.cache.php.". I suspect that with ajax requests one php process is creating a lock on the file while the other is trying to read it.

I will comment again as soon as i know more.

flip111 added a commit to flip111/metadata that referenced this issue Nov 18, 2013
Under, unfortunately unknown, circumstances rename() does not work properly under windows when the target file exists. See also this comment http:https://us2.php.net/manual/en/function.rename.php#60341 

When testing and removing the @ in front of rename() the following occured:

PHP Warning:  rename(C:\inetpub\symfony\app\cache\prod\jms_diextra\metadata\met666B.tmp,C:/inetpub/symfony/app/cache/prod/jms_diextra/metadata/.cache.php): Access is denied. (code: 5) in C:\inetpub\symfony\vendor\jms\metadata\src\Metadata\Cache\FileCache.php on line 98

This is a patch to fix the problem for the windows platform. Like the comment describes the function will no longer be atomic (rename vs unlink+copy). But it seems to be the best solution available.

Sometimes it happens, sometimes it doesn't, i'm afraid i can't pinpoint the exact cause without diving into PHP internals and C.

The problem was found investigating this issue schmittjoh#39
@sebastien-roch
Copy link

The problem is that if the metadata is an instance of NullMetadata, it has no name, hence creating a .cache.php file in cache. I'm wondering why the NullMetadata constructor doesn't take the classname as parameter in its constructor? ping @schmittjoh

@stof
Copy link
Contributor

stof commented Aug 27, 2014

this has been fixed in cc1f2b8 already

@sebastien-roch
Copy link

Thanks stof, I have to update.

@goetas goetas closed this as completed May 9, 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

No branches or pull requests

4 participants