Skip to content

Commit

Permalink
bug #18352 [Debug] Fix case sensitivity checks (nicolas-grekas)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.7 branch.

Discussion
----------

[Debug] Fix case sensitivity checks

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | yes
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #18344
| License       | MIT
| Doc PR        | -

Commits
-------

7336177 [Debug] Fix case sensitivity checks
  • Loading branch information
fabpot committed Mar 30, 2016
2 parents 03c28e4 + 7336177 commit 5083a35
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/Symfony/Component/Debug/DebugClassLoader.php
Expand Up @@ -51,15 +51,25 @@ public function __construct($classLoader)
}

if (!isset(self::$caseCheck)) {
if(!file_exists(strtolower(__FILE__))) {
$file = file_exists(__FILE__) ? __FILE__ : rtrim(realpath('.'), DIRECTORY_SEPARATOR);
$i = strrpos($file, DIRECTORY_SEPARATOR);
$dir = substr($file, 0, 1 + $i);
$file = substr($file, 1 + $i);
$test = strtoupper($file) === $file ? strtolower($file) : strtoupper($file);
$test = realpath($dir.$test);

if (false === $test || false === $i) {
// filesystem is case sensitive
self::$caseCheck = 0;
} elseif(realpath(strtolower(__FILE__)) === __FILE__) {
// filesystem is not case sensitive
} elseif (substr($test, -strlen($file)) === $file) {
// filesystem is case insensitive and realpath() normalizes the case of characters
self::$caseCheck = 1;
} else {
// filesystem is not case sensitive AND realpath() fails to normalize case
} elseif (false !== stripos(PHP_OS, 'darwin')) {
// on MacOSX, HFS+ is case insensitive but realpath() doesn't normalize the case of characters
self::$caseCheck = 2;
} else {
// filesystem case checks failed, fallback to disabling them
self::$caseCheck = 0;
}
}
}
Expand Down

3 comments on commit 5083a35

@alexchip64
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I wrong or it should be added to branch 2.8 as well?

@nicolas-grekas
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexchip64
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Sorry. :-)

Please sign in to comment.