Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/core#2590 - Remove unused function CRM_Utils_File::relativeDirectory #20270

Merged
merged 1 commit into from
May 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 0 additions & 32 deletions CRM/Utils/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -622,38 +622,6 @@ public static function isAbsolute($path) {
return FALSE;
}

/**
* @param $directory
*
* @return string
* @deprecated
* Computation of a relative path requires some base.
* This implementation is problematic because it relies on an
* implicit base which was constructed problematically.
*/
public static function relativeDirectory($directory) {
// Do nothing on windows
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
return $directory;
}

// check if directory is relative, if so return immediately
if (!self::isAbsolute($directory)) {
return $directory;
}

// make everything relative from the baseFilePath
$basePath = self::baseFilePath();
Copy link
Member

Choose a reason for hiding this comment

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

Yay! This removes another reference to ::baseFilePath()

// check if basePath is a substr of $directory, if so
// return rest of string
if (substr($directory, 0, strlen($basePath)) == $basePath) {
return substr($directory, strlen($basePath));
}

// return the original value
return $directory;
}

/**
* @param $directory
* @param string $basePath
Expand Down