Partner and Community Forums
Windows Cache Extension for PHP
Require_once Requires File Twice Under Wincache
Last post Dec 03, 2009 08:50 AM by don.raman
Sep 11, 2009 07:37 PM|LINK
After flawless testing on my dev machine (Vista x64 SP2, IIS 7) we installed wincache on the production server last night, and got a very strange result. We spent most of the morning testing and troubleshooting before we pinpointed what was happening.
We have the code
require_once('library/common.php') or require_once('common.php') in almost all of our files, and that seems to work fine. However, in one file we have it like this:
Because the file is called in different ways. The problem is that the primary file has the require_once('library/common.php') in it as well (sometimes that file is called alone, which is why we have the documet_root) and
what ends up occurring is common.php is loaded twice. I've done many tests and I am certain that this is happening. That's a problem because common.php has certain functions that cannot be run twice. We can probably work around this, but I feel we might
just pull it. I've disabled wincache in runtime and it stops this double loading.
Oh, and it's probably not hard to guess, but it's file cache specifically, not the op code cache.
One more thing, we have several dev sites on this server (on different ports, 90, 91, etc..) and it only does this on the primary (80) and on none of the other dev machines.
Sep 11, 2009 07:56 PM|LINK
I just realized something. The way we know it's loaded twice is we put code at the top of common.php that displays on the screen (can't use the debugger on the live site) and it displays twice at the top....why don't we get "cannot redeclare function" error
Sep 11, 2009 08:15 PM|LINK
Is it possible for you to give a small PHP code so that we can reproduce the problem at our end please?
Sep 11, 2009 08:41 PM|LINK
well, let's see....
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
The result with file cache enabled on my production server (Windows 2003 SP3, IIS 6) is
with file cache disabled or on my dev machine, the result is
Sep 11, 2009 09:39 PM|LINK
Thanks for the repro. I tried it out but I couldn't repro it on my machine. Any chance that multiple copies of common_test.php are present on the machine? Can you pls set wincache.debuglevel to 301 in php.ini, recycle php process, run dgbview (google and download
if you don't have it), run script again and paste the debug output you see in dbgview?
Sep 12, 2009 09:53 PM|LINK
I am not really sure how to use dbgview in this manner, but I'll try.
Sep 12, 2009 10:00 PM|LINK
I don't know how to use dbgview. I've done everything you ask, but nothing is happening with debugview.
Sep 12, 2009 10:03 PM|LINK
Had to turn on Capture Global Win32:
 WINCACHE: zend_resolve_path called for c:\inetpub\wwwroot\test.php
 WINCACHE: zend_stream_open_function called for c:\inetpub\wwwroot\test.php
 WINCACHE: compile_file called for c:\inetpub\wwwroot\test.php
 WINCACHE: zend_resolve_path called for library/common_test.php
 WINCACHE: relative path library/common_test.php is resolved path as C:\Inetpub\wwwroot\library\common_test.php
 WINCACHE: zend_stream_open_function called for C:\Inetpub\wwwroot\library\common_test.php
 WINCACHE: compile_file called for C:\Inetpub\wwwroot\library\common_test.php
 WINCACHE: zend_resolve_path called for library/test_code.php
 WINCACHE: relative path library/test_code.php is resolved path as C:\Inetpub\wwwroot\library\test_code.php
 WINCACHE: zend_stream_open_function called for C:\Inetpub\wwwroot\library\test_code.php
 WINCACHE: compile_file called for C:\Inetpub\wwwroot\library\test_code.php
 WINCACHE: zend_resolve_path called for c:\inetpub\wwwroot/library/common_test.php
 WINCACHE: zend_stream_open_function called for c:\inetpub\wwwroot\library\common_test.php
 WINCACHE: compile_file called for c:\inetpub\wwwroot\library\common_test.php
Sep 13, 2009 07:15 PM|LINK
Thanks for sending this trace. Looks like both times path correctly resolved to the same file. Thing which look suspicious is the difference in casing of "C:\Inetpub" part. I will try with different casing on my test machine and respond back.
Sep 15, 2009 06:11 PM|LINK
Many thanks for reporting this bug. We are able to have a small repro here, A bug has been filed in internal bug database. We will fix it in the next release.
Again thanks for all the time in reporting this.