Skip to content

Commit

Permalink
Fix usage of ROOT in deprecationWarning()
Browse files Browse the repository at this point in the history
This should fix errors when cakephp packages are used outside of the
framework.

Fixes #17138
  • Loading branch information
markstory committed May 16, 2023
1 parent d649029 commit f42dfdc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,12 @@ function deprecationWarning(string $message, int $stackFrame = 1): void
$frame = $trace[$stackFrame];
$frame += ['file' => '[internal]', 'line' => '??'];

$relative = str_replace(DIRECTORY_SEPARATOR, '/', substr($frame['file'], strlen(ROOT) + 1));
// Assuming we're installed in vendor/cakephp/cakephp/src/Core/functions.php
$root = dirname(dirname(dirname(dirname(dirname(__DIR__)))));
if (defined('ROOT')) {
$root = ROOT;
}
$relative = str_replace(DIRECTORY_SEPARATOR, '/', substr($frame['file'], strlen($root) + 1));
$patterns = (array)Configure::read('Error.ignoredDeprecationPaths');
foreach ($patterns as $pattern) {
$pattern = str_replace(DIRECTORY_SEPARATOR, '/', $pattern);
Expand Down

1 comment on commit f42dfdc

@tersmitten
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks @markstory

Please sign in to comment.