Welcome Guest, Not a member yet? Register   Sign In
CI bug with is_really_writable

This took me several hours to find, but I believe I have found the cause of a reproducible bug.

Basically the bug will exhibit itself when CI framework is ran several times in a short amount of time. You may be wondering why would someone do that, well for one I use GD to resize an image to thumbnail size before the user sees it. On the site that I am developing, on the admin side anyways, the user will see a list of all the products and a thumbnail of that picture. The "bug" would manifest itself by not displaying a thumbnail, even though when I went directly to it in a new tab the image displayed fine (and random other pictures would show/no show). The thumbnail img src is set to a CI controller that generates the thumbnail using PHP+GD. Which, the browser will execute every time it requests the picture. At first I thought Apache was doing something funky, but I noticed that the Content-Type to be "text/html" which is the *default* for PHP (at least in my install), the default for Apache is "text/plain" (again at least on my install). Also, Content-Length was 0, which would make some sense because there was no data.

So, doing some tests - I find that die(); or exit(); will product a Content-Type of "text/html" and Content-Length of 0. But, nothing in my code was making it die or exit and I couldn't find any calls to those functions inside of CI framework.

Checking out the CI logs I noticed some funny lines:
ERROR - 2009-08-15 13:25:16 --&gt; Severity: Warning --&gt; unlink(x:\system/cache/67c6a1e7ce56d3d6fa748ab6d9af3fd7) [<a href='function.unlink'>function.unlink</a>]: Permission denied C:\www\bethlemgifts.com\system\codeigniter\Common.php 63
I find that kind of funny because this is a Windows system and Apache as the "Local System" account, which meant that if Windows couldn't delete that file, then there was something really wrong here. But, when I went to go look at the cache directory it was blank every time (except for index.html, of course). Which I began to think - I believe that the system is running into sort of like a "deadlock" where the CI framework is trying to delete the same file. I examined line 63 in Common.php and found:
Well the error makes sense, but the code doesn't -
Quote:(Common.php)// For windows servers and safe_mode "on" installations we'll actually
Windows servers? Hmm, well then...my advice
Instead of trying to write then delete a file, just check the owner and permission mask. It should return proper values even in Windows. If you are really in need of a Windows specific test then try one of the following:
* Try Windows API to create/delete using w32api_register_function
* Try http://us2.php.net/manual/en/function.is....php#73596
* If the user has DB credentials in the config file, do all file I/O inside of the database and let the database server worry about file I/O.
* Delete the files at a later date, ie store the files to be deleted in a database and delete them 60 seconds later to let the OS, disk, script breathe.

[See post below, sorry ran out of characters!]

Messages In This Thread
CI bug with is_really_writable - by El Forum - 08-16-2009, 02:54 PM
CI bug with is_really_writable - by El Forum - 08-16-2009, 02:54 PM
CI bug with is_really_writable - by El Forum - 08-16-2009, 10:07 PM

Theme © iAndrew 2016 - Forum software by © MyBB