Skip to content

Commit

Permalink
Converts using deprated fatal function for exception in CRM/Utils/Sys…
Browse files Browse the repository at this point in the history
…tem and in CRM/Utils/Cache and changes default for retrieve function in the Request class to throw exceptions

Update doc blocks
  • Loading branch information
seamuslee001 committed Nov 8, 2019
1 parent fe8d0a0 commit d0d1083
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 8 deletions.
3 changes: 2 additions & 1 deletion CRM/Utils/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ class CRM_Utils_Cache {
* An array of configuration params.
*
* @return \CRM_Utils_Cache
* @throws \CRM_Core_Exception
*/
public function __construct(&$config) {
CRM_Core_Error::fatal(ts('this is just an interface and should not be called directly'));
throw new CRM_Core_Exception(ts('this is just an interface and should not be called directly'));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion CRM/Utils/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static function id() {
*
* @throws \CRM_Core_Exception
*/
public static function retrieve($name, $type, &$store = NULL, $abort = FALSE, $default = NULL, $method = 'REQUEST', $isThrowException = FALSE) {
public static function retrieve($name, $type, &$store = NULL, $abort = FALSE, $default = NULL, $method = 'REQUEST', $isThrowException = TRUE) {

$value = NULL;
switch ($method) {
Expand Down
2 changes: 1 addition & 1 deletion CRM/Utils/System/Backdrop.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ public function authenticate($name, $password, $loadCMSBootstrap = FALSE, $realP

$dbBackdrop = DB::connect($config->userFrameworkDSN);
if (DB::isError($dbBackdrop)) {
CRM_Core_Error::fatal("Cannot connect to Backdrop database via $config->userFrameworkDSN, " . $dbBackdrop->getMessage());
throw new CRM_Core_Exception("Cannot connect to Backdrop database via $config->userFrameworkDSN, " . $dbBackdrop->getMessage());
}

$account = $userUid = $userMail = NULL;
Expand Down
4 changes: 3 additions & 1 deletion CRM/Utils/System/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ public function url(
*
* @return array|bool
* [contactID, ufID, unique string] else false if no auth
* @throws \CRM_Core_Exception.
*/
public function authenticate($name, $password, $loadCMSBootstrap = FALSE, $realPath = NULL) {
return FALSE;
Expand Down Expand Up @@ -179,9 +180,10 @@ public function loadUser($user) {

/**
* Immediately stop script execution and display a 401 "Access Denied" page.
* @throws \CRM_Core_Exception
*/
public function permissionDenied() {
CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
throw new CRM_Core_Exception(ts('You do not have permission to access this page.'));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion CRM/Utils/System/Drupal.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ public function authenticate($name, $password, $loadCMSBootstrap = FALSE, $realP

$dbDrupal = DB::connect($config->userFrameworkDSN);
if (DB::isError($dbDrupal)) {
CRM_Core_Error::fatal("Cannot connect to drupal db via $config->userFrameworkDSN, " . $dbDrupal->getMessage());
throw new CRM_Core_Exception("Cannot connect to drupal db via $config->userFrameworkDSN, " . $dbDrupal->getMessage());
}

$account = $userUid = $userMail = NULL;
Expand Down
2 changes: 1 addition & 1 deletion CRM/Utils/System/Drupal6.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ public function authenticate($name, $password, $loadCMSBootstrap = FALSE, $realP

$dbDrupal = DB::connect($config->userFrameworkDSN);
if (DB::isError($dbDrupal)) {
CRM_Core_Error::fatal("Cannot connect to drupal db via $config->userFrameworkDSN, " . $dbDrupal->getMessage());
throw new CRM_Core_Exception("Cannot connect to drupal db via $config->userFrameworkDSN, " . $dbDrupal->getMessage());
}

$strtolower = function_exists('mb_strtolower') ? 'mb_strtolower' : 'strtolower';
Expand Down
3 changes: 2 additions & 1 deletion CRM/Utils/System/Joomla.php
Original file line number Diff line number Diff line change
Expand Up @@ -473,9 +473,10 @@ public function loadUser($username, $password = NULL) {

/**
* FIXME: Use CMS-native approach
* @throws \CRM_Core_Exception.
*/
public function permissionDenied() {
CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
throw new CRM_Core_Exception(ts('You do not have permission to access this page.'));
}

/**
Expand Down
3 changes: 2 additions & 1 deletion CRM/Utils/System/WordPress.php
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,10 @@ public function loadUser($user) {

/**
* FIXME: Use CMS-native approach
* @throws \CRM_Core_Exception
*/
public function permissionDenied() {
CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
throw new CRM_Core_Exception(ts('You do not have permission to access this page.'));
}

/**
Expand Down

0 comments on commit d0d1083

Please sign in to comment.