I get false whenever I use the function is_readable
on a file shared by my host on a VM, the expected result is true.
I am doing the setup of a local development environment for an existing projet. I don't want to use another function because it's a complex legacy system and I am afraid I would hide other potential problems I would stumble upon later in development.
The VM is set up using vagrant and virtualbox. The OS is a Windows Server 2008 machine with Zend Server with PHP 5.3 hosting code shared on the host, which is a Mac.
The shared folder is created as follow:
vmConfig.vm.synced_folder "/path/to/shared/folder/cms", '/cms', mount_options: ["dmode=775,fmode=664,type=smb"], owner: 'wcmadmin', group: 'wcmadmin'
A piece of code is trying to see if a file is readable. is_readable
returns false. I run the script via command line with both users wcmadmin
and Administrator
and I get the same results.
function smarty_core_assemble_plugin_filepath($params, &$smarty)
{
[...]
// try relative to cwd (or absolute)
if (is_readable($_plugin_filepath)) {
$_return = $_plugin_filepath;
break;
}
[...]
I did a test script to dig further:
echo 'is_readable: ';
var_export(is_readable('C:\cms\path\to\file\file.php'));
echo "\n";
echo 'require_once: ';
var_export(require_once('C:\cms\path\to\file\file.php'));
And I have the following results:
is_readable: false
require_once: true
Using file_get_contents
on the file returns the content correctly.
Using cygwin, the permissions on the file are as follow:
$ ls -al C:\cms\path\to\file\file.php
-rw-r--r-- 1 wcmadmin None 1498 Apr 18 07:22 C:\cms\path\to\file\file.php
Files path have been changed for the purpose of this question. While they may have some discrepancies, they resolve correctly during real tests.
It's a bug in virtual box and is still happening as of version 5.0.18.