Bug #79733 [NEW]: glob doesn't work with backslashes on linux
| From: | david dot hlavati at gmail dot com | Date: | Thu, 25 Jun 2020 10:02:51 +0000 |
| Subject: | Bug #79733 [NEW]: glob doesn't work with backslashes on linux | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-227648@lists.php.net to get a copy of this message | ||
From: david dot hlavati at gmail dot com
Operating system: CentOS7
PHP version: 7.4.7
Package: *General Issues
Bug Type: Bug
Bug description:glob doesn't work with backslashes on linux
Description:
------------
First: it's possible that it's a normal behavior and I just don't know
about it.
php 7.4.7 - maybe not version related
backstory:
So I would like to get a bunch of maintenance classes and initialize
them dynamically and I'm using the glob function for this as it's
written in the test script section. This works on windows 10, however it
returns with nothing on CentOS7. Forward slashes are fine in both cases,
but maybe conventionally it should work the same on both systems -
again; it's maybe a normal behavior. And - this is actually absolutely
irrelevant, but - the forward slash solution doesn't work for creating
the classes dynamically - unless if I replace the slashes before
creating the classes.
File structure:
The targeted classes I would like to locate with the glob function are
here:
common\\queue\\tasks\\maintenance\\
The script is running from here: common\\queue\\
Test script:
---------------
```
// maintenance classes are located here
$path = 'common\\queue\\tasks\\maintenance\\';
// only for testing purpose I'll store the classes here
$classes = [];
// this script file is in this path:
common\\queue\\whatever.php
foreach (glob(__DIR__ . "\\..\\..\\{$path}*.php") as $location)
{
$maintenanceClass = $path . basename($location, '.php');
$classes[] = $maintenanceClass;
// the line below is just an example as I would like to use
this
(new
$maintenanceClass)->initTask(BaseModel::getConfig('maintenanceFrequency'));
}
print_r($classes, true);
```
Expected result:
----------------
for example - if these files are on the desired place place:
Array
(
[0] => common\queue\tasks\maintenance\ActivatorMaintenance
[1] => common\queue\tasks\maintenance\CartMaintenance
[2] => common\queue\tasks\maintenance\EventLogMaintenance
)
Actual result:
--------------
Array
(
)
--
Edit bug report at https://bugs.php.net/bug.php?id=79733&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=79733&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=79733&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=79733&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=79733&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=79733&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=79733&r=support
Expected behavior: https://bugs.php.net/fix.php?id=79733&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=79733&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=79733&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=79733&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79733&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=79733&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=79733&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=79733&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=79733&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=79733&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=79733&r=mysqlcfg