Does Yii (Or Php Itself?) Have Some Sort Of Class Cache? How Do I Clean It?

Hi,

I’m literally freaking out. I have a php file called Whatever.php in the “components” folder which contains a class definition for class Whatever which is an application component.

I have modified and saved the file. Now when I call the application from a browser, the old version is being executed. I am 100% positive about this. I can vim the php file on the server and see it’s my new version, but then I refresh teh page from the browser, I look at the application.log, and the newly logged traces are clearly from the old version. That is, the old version is being run NOW.

Does Yii have some sort of php class caching mechanism of its own that may have a bug? If not, does PHP itself?

What else could be causing PHP to “remember” an old version of a php file that has already been overwritten????

I had never observed such a thing before.

thanks in advance

m.

Hi matteosistisette

are you sure that is not enabled any cache ? (on your server or by Yii) ?

remove temporarly this file and test it again

Also are you sure that you don’t use another components ? disable the code that use this component and try then

It MUST be some cache. If it’s of Yii, I haven’t enabled it unless it is by default.

But I guess it’s the server or PHP.

I’ve read about ACP, but I’m not sure I have ACP enabled on my php installation (or is it bundled with php by default??) The output of my phpinfo() doesn’t even contain the string “acp”.

Even deleting the file it runs as if the file was still there (the old version that doesn’t exist anyway)!!! It’s crazy. Whatever cache this is, it doesn’t work in any reasonable way (no decent cache system retains a cached copy of a file that has been modified). The strange thing is that this had never happened to me before and, needless to say, I had already been modifying-and-testing scripts all the time zillions of times, and I always, always observed the changes immediately. Why all of a sudden the cache got “frozen” and stopped updating is beyond me.

It looks like there are tons of PHP opcode caching systems, I just wonder how to figure out which one on earth I am using so that I can look fro how to manually flush/clear it.

Here’s my phpinfo:

http://megafone.net/phpinfo.php

I guess you have accidentally created 2 "components" directory.

You are loading and editing the file in one, while http server is serving the file in the other.

This is only a guess, but would you please double check the whole directory of your site?

No, that’s not the case.

I have no other file with the same name anywhere at all, and of course no duplicate components folder.

I have double checked

As far as I know, Yii is not related to this problem. Yii doesn’t cache php file contents by itself.

PHP extensions like APC, XCache or MemCache may do it, but your phpinfo doesn’t report any of them. So I don’t think that php is to be blamed.

And if you haven’t changed any configuration of apache, I think it is irrelevant also.

So, the chances are, you have 2 Whatever.php: one in the componets directory and the other in somewhere else. I would search for the old Whatever.php in some corner of your directories. Sorry if I’m wrong.

[EDIT]

MemCache doesn’t do opcode caching …

Not to be annoying, but have you looked for the string APC instead of ACP? (as that is how it’s called).

Just wanted to make sure that you didn’t just make a typo here first.

LOL yes sorry, I mistyped it here but I searched correctly. I searched both just in case :)

Ok so it’s not Yii. No way I have 2 Whatever.php, nor even 2 Whatever classes. I have find’ed and grep’ed. I have only the new one in the whole filesystem.

So if I don’t have any cache-related extension, is there any documentation out there about PHP’s mysterious “own” or “native” or “internal” cache that surprisingly is not mentioned anywhere (I can find) in PHP’s documentation, where I could find how to manually flush it when it miserably fails to automatically update?

Hmm, I’m sorry but I don’t have any idea. :-[

I would try:

  1. Delete all the existing files/directories.

  2. Upload all of them once again.

And probably:

  1. Restart apache.

Huh, what a rude operation, though … ;D

Another idea: Do you have any proxies in between or does your browser cache pretty aggressively? Perhaps it’s not backend related at all but its your browser cache or something in between (Perhaps try a hard-refresh?)

@Blitzz:

But matteosistisette has checked the logged traces.

@matteosistisette:

Well, what the source file of that trace? Does it point to the path of your Whatever.php?

Yeah, and it points to a line that no longer exists.

It’s clearly some compiled opcode that is running, which is not from the new source. I just can’t figure out which damn cache system PHP is using and how to force a recompile (which should be done automatically whenever a source is modified, and used to be that way, but however…)

The phpinfo() doesn’t show any information about any kind of cache, and PHP documentation doesn’t say anything about a “default” or “native” opcode cache, other than APC which is not installed on my php… this is all so crazy

You are logging into the wrong server - rename index.php to see for yourself… the site will still run just fine.

Don’t be ridiculous, that’s NOT the case. This is the same server I’ve been logging into for years, and there’s no other server where I have any copy of these files, so I couldn’t be possibly logging into another server believing it’s the same one.

Sh* sh* sh* sh*!

It WAS a duplicate file mistake, at the end!!!!!!!! There was a copy of the old version of the file OUTSIDE the protected directory, in the webroot. Obviously copied by accident (don’t know how) in some uploading or rsyncing operation at some moment.

In all my double-checks, I always searched and grepped only the "protected" folder, not outside of it.

It’s damn strange, though, that Yii loads a php file that is outside the protected directory. I wouldn’t have ever expected it to…

Ridiculous? … its actually known as a sense of humor.