php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69609 rmdir/unlink function reroutes do not clear resolve path cache
Submitted: 2015-05-08 20:24 UTC Modified: 2015-05-21 20:55 UTC
From: ericsten@php.net Assigned: ericsten (profile)
Status: Closed Package: WinCache (PECL)
PHP Version: Irrelevant OS: Windows
Private report: No CVE-ID: None
 [2015-05-08 20:24 UTC] ericsten@php.net
Description:
------------
Problem:
When function rerouting is enabled (wincache.reroute_enabled=1), the WinCache 
wrappers for unlink/rmdir do not clear the resolve path cache.  Subsequent
calls to file_exists erroneously report the removed files as still existing.

Test script:
---------------
<?php

$tmpdir = sys_get_temp_dir() . "/ericsten/";
$wait = 1;
$max_wait = 10;

/* pre-create */

if (file_exists($tmpdir))
{
    echo "Directory: " . $tmpdir . " Exists, and it shouldn't! <BR>\n";
}

/* create */
mkdir($tmpdir);

/* verfiy */
if (file_exists($tmpdir))
{
    echo "Directory: " . $tmpdir . " Created! <BR>\n";
}
else
{
    http_response_code(500);
    echo "Directory: " . $tmpdir . " Failed to create? <BR>\n";
}

/* remove */
rmdir($tmpdir);

/* verify removed */
if (file_exists($tmpdir))
{
    http_response_code(500);
    echo "Directory: " . $tmpdir . " Exists, even though we deleted it! <BR>\n";
}
else
{
    echo "Directory: " . $tmpdir . " Removed. <BR>\n";
    exit;
}

/* wait if not removed */
$total_wait = 0;
while ($total_wait < $max_wait)
{
    sleep($wait);
    $total_wait += $wait;
    if (file_exists($tmpdir))
    {
        http_response_code(500);
        echo "Directory: " . $tmpdir . " Still Exists, even though we waited ". $total_wait ." seconds! <BR>\n";
    }
    else
    {
        http_response_code(200);
        echo "Directory: " . $tmpdir . " Removed after " . $total_wait . " seconds. <BR>\n";
        break;
    }
}

?>

Expected result:
----------------
immediately after calling rmdir or unlink, the file_exists function should return FALSE for the removed item.

Actual result:
--------------
WordPress updates fail to install, and winds up deleting the existing theme/extension because it thinks the directory still exists.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-05-08 20:25 UTC] ericsten@php.net
-Assigned To: +Assigned To: ericsten
 [2015-05-08 20:25 UTC] ericsten@php.net
Issue exists in WinCache Version 1.3.7.4.
 [2015-05-21 17:10 UTC] ericsten@php.net
Automatic comment from SVN on behalf of ericsten
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=336818
Log: Bug 69609: rmdir/unlink function reroutes do not clear resolve path cache
 [2015-05-21 20:55 UTC] ericsten@php.net
-Status: Assigned +Status: Closed
 [2015-05-21 20:55 UTC] ericsten@php.net
fix checked in.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 14:01:30 2024 UTC