<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
+ | Copyright CiviCRM LLC. All rights reserved. |
| |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License and the CiviCRM Licensing Exception along |
- | with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
+ | This work is published under the GNU AGPLv3 license with some |
+ | permitted exceptions and without any warranty. For full license |
+ | and copyright information, see https://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2019
+ * @copyright CiviCRM LLC https://civicrm.org/licensing
*/
/**
if (FALSE === file_get_contents($fileName)) {
// Our file cannot be found.
// Using 'die' here breaks this on extension upgrade.
- throw new CRM_Exception('Could not find the SQL file.');
+ throw new CRM_Core_Exception('Could not find the SQL file.');
}
self::runSqlQuery($dsn, file_get_contents($fileName), $prefix, $dieOnErrors);
* @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
/**
* @param $directory
- * @param string|NULL $basePath
+ * @param string $basePath
* The base path when evaluating relative paths. Should include trailing slash.
*
* @return string
*/
- public static function absoluteDirectory($directory, $basePath = NULL) {
+ public static function absoluteDirectory($directory, $basePath) {
// check if directory is already absolute, if so return immediately
// Note: Windows PHP accepts any mix of "/" or "\", so "C:\htdocs" or "C:/htdocs" would be a valid absolute path
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' && preg_match(';^[a-zA-Z]:[/\\\\];', $directory)) {
return $directory;
}
- // make everything absolute from the baseFilePath
- $basePath = ($basePath === NULL) ? self::baseFilePath() : $basePath;
+ if ($basePath === NULL) {
+ // Previous versions interpreted `NULL` to mean "default to `self::baseFilePath()`".
+ // However, no code in the known `universe` relies on this interpretation, and
+ // the `baseFilePath()` function is problematic/deprecated.
+ throw new \RuntimeException("absoluteDirectory() requires specifying a basePath");
+ }
// ensure that $basePath has a trailing slash
$basePath = self::addTrailingSlash($basePath);