Cphalcon: [BUG]: PHP 7.3.5 and 7.4.1 windows folder name ending with period not working

Created on 18 Feb 2020  路  10Comments  路  Source: phalcon/cphalcon

Warning: mkdir(): Permission denied

https://github.com/phalcon/cphalcon/blob/4.0.x/phalcon/Helper/Str.zep#L210

cache file name has dots in it, e.g; index.12321321.cache.html

$dir = 'index.12321321.cache.html';
$cache = new Phalcon\Cache($adapter);
$cache->set($dir, 'hello world', 30);
// phalcon/Helper/Str::dirFromFile(string! file)
// mkdir(directory, 0777, true);

Details

  • Phalcon version: 4.0.3 & 4.0.4
  • PHP Version: 7.4.1
  • Operating System: Windows 10
bug low

All 10 comments

Can you try with $recursive = true ?

mkdir($dir, null, true);

@Jeckerson https://github.com/phalcon/cphalcon/blob/4.0.x/phalcon/Storage/Adapter/Stream.zep#L277

if !is_dir(directory) {
  mkdir(directory, 0777, true);
}

Are you on Phalcon 4.0.4?

@ruudboon 4.0.3

Updated to 4.0.4 and problem persists

Thnx for testing on the upgrade. I did some fixes in 4.0.1 related in this area so wanted to be sure you鈥檙e not on 4.0.0.
I think @Jeckerson is on it.

After tests in all 3 envs (Linux and Mac) via integration tests. Meanwhile Windows tests I did manually.
So the problem is in Windows (partially) and in PHP mainly.

In Windows, if you try to create folder with dot at the end, it will remove it and create without it.
2020-02-25_14-32-07

Same thing if create via cmd and mkir command.

Meanwhile in PHP it will output error and do not create an folder:

PHP Warning:  mkdir(): Permission denied

Probably make sense to report bug to PHP...

@naumanjkhan Any way, in your case, just replace . dots with - in filename and it will work.

/cc @phalcon/core-team Suggestions what to do from our side.

@Jeckerson thank you for suggestion but that is what I have already done, changed the file name. But I will have to remember it and will have to replace wherever I am using the filename with dots for cache.

Wouldn't it be possible if it is handled internally and developers don't have to remember about replacing dots on windows environment (an extra burden)?

@Jeckerson I think the best approach on this would be to replace the . with - when we create the subfolders and handle it internally.

Resolved in https://github.com/phalcon/cphalcon/pull/14893

Thank you @naumanjkhan

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sharptry picture sharptry  路  3Comments

fonqing picture fonqing  路  3Comments

TimurFlush picture TimurFlush  路  3Comments

EquaI1ty picture EquaI1ty  路  3Comments

gytsen picture gytsen  路  3Comments