*
* @return array
* Array of event summary values
+ *
+ * @throws CRM_Core_Exception
*/
public static function getGrantStatusOptGroup() {
$og = CRM_Core_BAO_OptionGroup::retrieve($params, $defaults);
if (!$og) {
- CRM_Core_Error::fatal('No option group for grant statuses - database discrepancy! Make sure you loaded civicrm_data.mysql');
+ throw new CRM_Core_Exception('No option group for grant statuses - database discrepancy! Make sure you loaded civicrm_data.mysql');
}
return $og;
private $commonIncluded = FALSE;
/**
- * @var array(string)
+ * @var array|string
*/
private $commonCiviModules = [];
* @param mixed $arg6
*
* @return array|bool
- * @throws \Exception
+ * @throws \CRM_Core_Exception
*/
public function runHooks(
$civiModules, $fnSuffix, $numParams,
break;
default:
- CRM_Core_Error::fatal(ts('Invalid hook invocation'));
- break;
+ throw new CRM_Core_Exception(ts('Invalid hook invocation'));
}
if (!empty($fResult) &&
* @param string $localFile
* Path at which to store the .zip file.
* @return STATUS_OK|STATUS_WRITE_ERROR|STATUS_DL_ERROR
+ *
+ * @throws CRM_Core_Exception
*/
public function fetch($remoteFile, $localFile) {
// Download extension zip file ...
if (!function_exists('curl_init')) {
- CRM_Core_Error::fatal('Cannot install this extension - curl is not installed!');
+ throw new CRM_Core_Exception('Cannot install this extension - curl is not installed!');
}
list($ch, $caConfig) = $this->createCurl($remoteFile);
if (preg_match('/^https:/', $remoteFile) && !$caConfig->isEnableSSL()) {
- CRM_Core_Error::fatal('Cannot install this extension - does not support SSL');
+ throw new CRM_Core_Exception('Cannot install this extension - does not support SSL');
}
$fp = @fopen($localFile, "w");
* to the mailer through the container.
*
* @return Mail
+ *
+ * @throws CRM_Core_Exception
*/
public static function createMailer() {
$mailingInfo = Civi::settings()->get('mailing_backend');
elseif ($mailingInfo['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_SMTP) {
if ($mailingInfo['smtpServer'] == '' || !$mailingInfo['smtpServer']) {
CRM_Core_Error::debug_log_message(ts('There is no valid smtp server setting. Click <a href=\'%1\'>Administer >> System Setting >> Outbound Email</a> to set the SMTP Server.', [1 => CRM_Utils_System::url('civicrm/admin/setting/smtp', 'reset=1')]));
- CRM_Core_Error::fatal(ts('There is no valid smtp server setting. Click <a href=\'%1\'>Administer >> System Setting >> Outbound Email</a> to set the SMTP Server.', [1 => CRM_Utils_System::url('civicrm/admin/setting/smtp', 'reset=1')]));
+ throw new CRM_Core_Exception(ts('There is no valid smtp server setting. Click <a href=\'%1\'>Administer >> System Setting >> Outbound Email</a> to set the SMTP Server.', [1 => CRM_Utils_System::url('civicrm/admin/setting/smtp', 'reset=1')]));
}
$params['host'] = $mailingInfo['smtpServer'] ? $mailingInfo['smtpServer'] : 'localhost';
!$mailingInfo['sendmail_path']
) {
CRM_Core_Error::debug_log_message(ts('There is no valid sendmail path setting. Click <a href=\'%1\'>Administer >> System Setting >> Outbound Email</a> to set the sendmail server.', [1 => CRM_Utils_System::url('civicrm/admin/setting/smtp', 'reset=1')]));
- CRM_Core_Error::fatal(ts('There is no valid sendmail path setting. Click <a href=\'%1\'>Administer >> System Setting >> Outbound Email</a> to set the sendmail server.', [1 => CRM_Utils_System::url('civicrm/admin/setting/smtp', 'reset=1')]));
+ throw new CRM_Core_Exception(ts('There is no valid sendmail path setting. Click <a href=\'%1\'>Administer >> System Setting >> Outbound Email</a> to set the sendmail server.', [1 => CRM_Utils_System::url('civicrm/admin/setting/smtp', 'reset=1')]));
}
$params['sendmail_path'] = $mailingInfo['sendmail_path'];
$params['sendmail_args'] = $mailingInfo['sendmail_args'];
/**
* Process the mailboxes that aren't default (ie. that aren't used by civiMail for the bounce).
+ *
+ * @return bool
+ *
+ * @throws CRM_Core_Exception.
*/
public static function processActivities() {
$dao = new CRM_Core_DAO_MailSettings();
self::_process(FALSE, $dao, TRUE);
}
if (!$found) {
- CRM_Core_Error::fatal(ts('No mailboxes have been configured for Email to Activity Processing'));
+ throw new CRM_Core_Exception(ts('No mailboxes have been configured for Email to Activity Processing'));
}
return $found;
}
* Create activities.
*
* @throws Exception
+ * @throws CRM_Core_Exception
*/
public static function _process($civiMail, $dao, $is_create_activities) {
// 0 = activities; 1 = bounce;
: CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Inbound Email');
if (!$emailActivityTypeId) {
- CRM_Core_Error::fatal(ts('Could not find a valid Activity Type ID for Inbound Email'));
+ throw new CRM_Core_Exception(ts('Could not find a valid Activity Type ID for Inbound Email'));
}
$config = CRM_Core_Config::singleton();
$message = ts('Could not connect to MailStore for ') . $dao->username . '@' . $dao->server . '<p>';
$message .= ts('Error message: ');
$message .= '<pre>' . $e->getMessage() . '</pre><p>';
- CRM_Core_Error::fatal($message);
+ throw new CRM_Core_Exception($message);
}
// process fifty at a time, CRM-4002
const XML_VALUE_SEPARATOR = ":;:;:;";
/**
- * @var array description of export field mapping
+ * @var array
+ * Description of export field mapping
*
* @code
* 'exampleEntityMappingName' => array(
*
* @return string
* XML
+ * @throws CRM_Core_Exception
*/
public function toXML() {
$buffer = '<?xml version="1.0" encoding="iso-8859-1" ?>';
$buffer .= " </{$this->_xml[$key]['scope']}>\n";
}
elseif ($this->_xml[$key]['required']) {
- CRM_Core_Error::fatal("No records in DB for $key");
+ throw new CRM_Core_Exception("No records in DB for $key");
}
}
$buffer .= "</CustomData>\n";
* @param $xml
* @param $idMap
*
- * @throws Exception
+ * @throws CRM_Core_Exception
*/
public function profileFields(&$xml, &$idMap) {
foreach ($xml->ProfileFields as $profileFieldsXML) {
];
$cfID = CRM_Core_DAO::singleValueQuery($sql, $params);
if (!$cfID) {
- CRM_Core_Error::fatal(ts("Could not find custom field for %1, %2, %3",
+ throw new CRM_Core_Exception(ts("Could not find custom field for %1, %2, %3",
[
1 => $profileField->field_name,
2 => $tableName,
* Returns TRUE if the requirement is met, FALSE if the requirement is not
* met and we're not aborting due to the failed requirement. If $abort is
* TRUE and the requirement fails, this function does not return.
+ *
+ * @throws CRM_Core_Exception
*/
public static function checkPHPVersion($ver = 5, $abort = TRUE) {
$phpVersion = substr(PHP_VERSION, 0, 1);
}
if ($abort) {
- CRM_Core_Error::fatal(ts('This feature requires PHP Version %1 or greater',
+ throw new CRM_Core_Exception(ts('This feature requires PHP Version %1 or greater',
[1 => $ver]
));
}
*
* @return string
* civicrm version
+ *
+ * @throws CRM_Core_Exception
*/
public static function version() {
static $version;
// pattern check
if (!CRM_Utils_System::isVersionFormatValid($version)) {
- CRM_Core_Error::fatal('Unknown codebase version.');
+ throw new CRM_Core_Exception('Unknown codebase version.');
}
}
*
* @param bool|FALSE $abort
*
- * @throws \Exception
+ * @throws \CRM_Core_Exception
*/
public static function redirectToSSL($abort = FALSE) {
$config = CRM_Core_Config::singleton();
Civi::log()->warning('CiviCRM thinks site is not SSL, redirecting to {url}', ['url' => $url]);
if (!self::checkURL($url, TRUE)) {
if ($abort) {
- CRM_Core_Error::fatal('HTTPS is not set up on this machine');
+ throw new CRM_Core_Exception('HTTPS is not set up on this machine');
}
else {
CRM_Core_Session::setStatus(ts('HTTPS is not set up on this machine'), ts('Warning'), 'alert');
* @param string $type
* The type to verify against.
* @param bool $abort
- * If TRUE, the operation will CRM_Core_Error::fatal() on invalid data.
+ * If TRUE, the operation will throw an CRM_Core_Exception on invalid data.
*
* @return mixed
* The data, escaped if necessary.
break;
default:
- CRM_Core_Error::fatal(
+ throw new CRM_Core_Exception(
$type . " is not a recognised (camel cased) data type."
);
- break;
}
// @todo Use exceptions instead of CRM_Core_Error::fatal().
if ($abort) {
$data = htmlentities($data);
- CRM_Core_Error::fatal("$data is not of the type $type");
+ throw new CRM_Core_Exception("$data is not of the type $type");
}
return NULL;
}
*/
class CRM_Utils_Weight {
/**
- * @var array, list of GET fields which must be validated
+ * List of GET fields which must be validated
*
* To reduce the size of this patch, we only sign the exploitable fields
* which make up "$baseURL" in addOrder() (eg 'filter' or 'dao').
* Less-exploitable fields (eg 'dir') are left unsigned.
* 'id','src','dst','dir'
+ * @var array
*/
public static $SIGNABLE_FIELDS = ['reset', 'dao', 'idName', 'url', 'filter'];
}
}
+ /**
+ *
+ * @throws CRM_Core_Exception
+ */
public static function fixOrder() {
$signature = CRM_Utils_Request::retrieve('_sgn', 'String');
$signer = new CRM_Utils_Signer(CRM_Core_Key::privateKey(), self::$SIGNABLE_FIELDS);
// Validate $_GET values b/c subsequent code reads $_GET (via CRM_Utils_Request::retrieve)
if (!$signer->validate($signature, $_GET)) {
- CRM_Core_Error::fatal('Request signature is invalid');
+ throw new CRM_Core_Exception('Request signature is invalid');
}
// Note: Ensure this list matches self::$SIGNABLE_FIELDS
* "civicrm/ajax/anulgar-modules" route).
*
* @deprecated
+ *
+ * @throws \CRM_Core_Exception
*/
public function run() {
/**
break;
default:
- \CRM_Core_Error::fatal("Unrecognized format");
+ throw new \CRM_Core_Exception("Unrecognized format");
}
\CRM_Utils_System::civiExit();
$handle = fopen($csvFile, "r");
if (!$handle) {
- CRM_Core_Error::fatal("Can't locate csv file.");
+ throw new CRM_Core_Exception("Can't locate csv file.");
}
require_once "CRM/Contribute/BAO/Contribution/Utils.php";
CRM_Core_Error::debug_log_message("Considering first row ( line $row ) as HEADER ..<p>", TRUE);
if (empty($header)) {
- CRM_Core_Error::fatal("Header is empty.");
+ throw new CRM_Core_Exception("Header is empty.");
}
}
$row++;
CRM_Core_DAO::$_nullObject, FALSE, 0, 'REQUEST'
);
if ($start < $end) {
- CRM_Core_Error::fatal("Start offset can't be less than End offset.");
+ throw new CRM_Core_Exception("Start offset can't be less than End offset.");
}
$start = date('Y-m-d', time() - $start * 24 * 60 * 60) . 'T00:00:00.00Z';