//CRM-5679
foreach ($params as $name => & $val) {
- if ($val && in_array($name, array(
- 'newBaseDir', 'newSiteName'))) {
+ if ($val && in_array($name, array('newBaseDir', 'newSiteName'))) {
$val = CRM_Utils_File::addTrailingSlash($val);
}
}
//CRM-15365 - Fix BaseURL to avoid wrong trailing slash on Windows installs
- foreach ($params as $name => & $val) {
- if ($val && in_array($name, array(
- 'newBaseURL'))) {
+ foreach ($params as $name => & $val) {
+ if ($val && in_array($name, array('newBaseURL'))) {
$val = CRM_Utils_File::addTrailingSlash($val,"/");
}
}
}
/**
- * Appends trailing slashed to paths
+ * Appends a slash to the end of a string if it doesn't already end with one
*
- * @param $name
- * @param null $separator
+ * @param string $path
+ * @param string $slash
*
* @return string
* @access public
* @static
*/
- static function addTrailingSlash($name, $separator = NULL) {
- if (!$separator) {
- $separator = DIRECTORY_SEPARATOR;
+ static function addTrailingSlash($path, $slash = NULL) {
+ if (!$slash) {
+ // FIXME: Defaulting to backslash on windows systems can produce unexpected results, esp for URL strings which should always use forward-slashes.
+ // I think this fn should default to forward-slash instead.
+ $slash = DIRECTORY_SEPARATOR;
}
-
- if (!in_array(substr($name, -1, 1), array('/', '\\'))) {
- $name .= $separator;
+ if (!in_array(substr($path, -1, 1), array('/', '\\'))) {
+ $path .= $slash;
}
- return $name;
+ return $path;
}
/**