本文整理汇总了PHP中JError::getErrorHandling方法的典型用法代码示例。如果您正苦于以下问题:PHP JError::getErrorHandling方法的具体用法?PHP JError::getErrorHandling怎么用?PHP JError::getErrorHandling使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JError
的用法示例。
在下文中一共展示了JError::getErrorHandling方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveErrorHandlers
/**
* Saves the current state of the JError error handlers.
*
* @return void
*/
protected function saveErrorHandlers()
{
$this->savedErrorState = array();
$this->savedErrorState[E_NOTICE] = JError::getErrorHandling(E_NOTICE);
$this->savedErrorState[E_WARNING] = JError::getErrorHandling(E_WARNING);
$this->savedErrorState[E_ERROR] = JError::getErrorHandling(E_ERROR);
}
示例2: saveErrorHandlers
/**
* Saves the current state of the JError error handlers.
*
* @return void
*
* @deprecated 13.1
* @since 12.1
*/
protected function saveErrorHandlers()
{
$this->_stashedErrorState = array();
// Handle optional usage of JError until removed.
if (class_exists('JError')) {
$this->_stashedErrorState[E_NOTICE] = JError::getErrorHandling(E_NOTICE);
$this->_stashedErrorState[E_WARNING] = JError::getErrorHandling(E_WARNING);
$this->_stashedErrorState[E_ERROR] = JError::getErrorHandling(E_ERROR);
}
}
示例3: throwError
/**
* Throw an error
*
* @param object &$exception An exception to throw.
*
* @return reference
*
* @deprecated 12.1 Use PHP Exception
* @see JException
* @since 11.1
*/
public static function throwError(&$exception)
{
// Deprecation warning.
JLog::add('JError::throwError() is deprecated.', JLog::WARNING, 'deprecated');
static $thrown = false;
// If thrown is hit again, we've come back to JError in the middle of throwing another JError, so die!
if ($thrown) {
self::handleEcho($exception, array());
// Inifite loop.
jexit();
}
$thrown = true;
$level = $exception->get('level');
// See what to do with this kind of error
$handler = JError::getErrorHandling($level);
$function = 'handle' . ucfirst($handler['mode']);
if (is_callable(array('JError', $function))) {
$reference = call_user_func_array(array('JError', $function), array(&$exception, isset($handler['options']) ? $handler['options'] : array()));
} else {
// This is required to prevent a very unhelpful white-screen-of-death
jexit('JError::raise -> Static method JError::' . $function . ' does not exist.' . ' Contact a developer to debug' . '<br /><strong>Error was</strong> ' . '<br />' . $exception->getMessage());
}
// We don't need to store the error, since JException already does that for us!
// Remove loop check
$thrown = false;
return $reference;
}
示例4: getContact
/**
* Returns contact details or user details as fall back
*
* @param int id key of user
* @param string attrib Requested attribute of the user object
* @return mixed row Attribute or row object
*/
public static function getContact($id, $attrib = 'Object')
{
$db = JFactory::getDBO();
static $rows = array();
if ($id <= 0) {
return null;
}
if (!isset($rows[$id])) {
$user = JFactory::getUser();
$rows[$id] = null;
$query = "SELECT ju.id, ju.name, ju.username, ju.sendEmail, ju.email, cd.name as contactname, " . ' CASE WHEN CHAR_LENGTH(cd.alias) THEN CONCAT_WS(\':\', cd.id, cd.alias) ELSE cd.id END as slug, ' . ' CASE WHEN CHAR_LENGTH(cat.alias) THEN CONCAT_WS(\':\', cat.id, cat.alias) ELSE cat.id END AS catslug ' . " \n FROM #__users AS ju" . "\n LEFT JOIN #__contact_details AS cd ON cd.user_id = ju.id " . "\n LEFT JOIN #__categories AS cat ON cat.id = cd.catid " . "\n WHERE block ='0'" . "\n AND cd.published =1 " . "\n AND cd.access " . (version_compare(JVERSION, '1.6.0', '>=') ? ' IN (' . JEVHelper::getAid($user) . ')' : ' <= ' . JEVHelper::getAid($user)) . "\n AND cat.access " . (version_compare(JVERSION, '1.6.0', '>=') ? ' IN (' . JEVHelper::getAid($user) . ')' : ' <= ' . JEVHelper::getAid($user)) . "\n AND ju.id = " . $id;
$db->setQuery($query);
$rows[$id] = $db->loadObject();
if (is_null($rows[$id])) {
// if the user has been deleted then try to suppress the warning
// this causes a problem in Joomla 2.5.1 on some servers
if (version_compare(JVERSION, '2.5', '>=')) {
$rows[$id] = JEVHelper::getUser($id);
} else {
$handlers = JError::getErrorHandling(2);
JError::setErrorHandling(2, "ignore");
$rows[$id] = JEVHelper::getUser($id);
foreach ($handlers as $handler) {
if (!is_array($handler)) {
JError::setErrorHandling(2, $handler);
}
}
if ($rows[$id]) {
$error = JError::getError(true);
}
}
}
}
if ($attrib == 'Object') {
return $rows[$id];
} elseif (isset($rows[$id]->{$attrib})) {
return $rows[$id]->{$attrib};
} else {
return null;
}
}
示例5: updateSchema
/**
* Creates or updates the database schema
*
* @return void
*
* @throws Exception When a database query fails and it doesn't have the canfail flag
*/
public function updateSchema()
{
// Get the schema XML file
$xml = $this->findSchemaXml();
if (empty($xml)) {
return;
}
// Make sure there are SQL commands in this file
if (!$xml->sql) {
return;
}
// Walk the sql > action tags to find all tables
$tables = array();
/** @var SimpleXMLElement $actions */
$actions = $xml->sql->children();
/** @var SimpleXMLElement $action */
foreach ($actions as $action) {
// Get the attributes
$attributes = $action->attributes();
// Get the table / view name
$table = $attributes->table ? $attributes->table : '';
if (empty($table)) {
continue;
}
// Am I allowed to let this action fail?
$canFailAction = $attributes->canfail ? $attributes->canfail : 0;
// Evaluate conditions
$shouldExecute = true;
/** @var SimpleXMLElement $node */
foreach ($action->children() as $node) {
if ($node->getName() == 'condition') {
// Get the operator
$operator = $node->attributes()->operator ? (string) $node->attributes()->operator : 'and';
$operator = empty($operator) ? 'and' : $operator;
$condition = $this->conditionMet($table, $node);
switch ($operator) {
case 'not':
$shouldExecute = $shouldExecute && !$condition;
break;
case 'or':
$shouldExecute = $shouldExecute || $condition;
break;
case 'nor':
$shouldExecute = $shouldExecute || !$condition;
break;
case 'xor':
$shouldExecute = ($shouldExecute xor $condition);
break;
case 'maybe':
$shouldExecute = $condition ? true : $shouldExecute;
break;
default:
$shouldExecute = $shouldExecute && $condition;
break;
}
}
if (!$shouldExecute) {
break;
}
}
// Make sure all conditions are met
if (!$shouldExecute) {
continue;
}
// Execute queries
foreach ($action->children() as $node) {
if ($node->getName() == 'query') {
$canFail = $node->attributes->canfail ? $node->attributes->canfail : $canFailAction;
$this->db->setQuery((string) $node);
try {
if (version_compare(JVERSION, '3.1', 'lt')) {
$handlers = array(E_NOTICE => JError::getErrorHandling(E_NOTICE), E_WARNING => JError::getErrorHandling(E_WARNING), E_ERROR => JError::getErrorHandling(E_ERROR));
$handlers[E_NOTICE]['options'] = isset($handlers[E_NOTICE]['options']) ? $handlers[E_NOTICE]['options'] : null;
$handlers[E_WARNING]['options'] = isset($handlers[E_WARNING]['options']) ? $handlers[E_WARNING]['options'] : null;
$handlers[E_ERROR]['options'] = isset($handlers[E_ERROR]['options']) ? $handlers[E_ERROR]['options'] : null;
JError::setErrorHandling(E_NOTICE, 'ignore');
JError::setErrorHandling(E_WARNING, 'ignore');
JError::setErrorHandling(E_ERROR, 'ignore');
}
$this->db->execute();
if (version_compare(JVERSION, '3.1', 'lt')) {
JError::setErrorHandling(E_NOTICE, $handlers[E_NOTICE]['mode'], $handlers[E_NOTICE]['options']);
JError::setErrorHandling(E_WARNING, $handlers[E_WARNING]['mode'], $handlers[E_WARNING]['options']);
JError::setErrorHandling(E_ERROR, $handlers[E_ERROR]['mode'], $handlers[E_ERROR]['options']);
}
if (version_compare(JVERSION, '3.1', 'lt') && $this->db->getErrorNum()) {
if (!$canFail) {
JError::raise(E_WARNING, $this->db->getErrorNum(), $this->db->getErrorMsg());
}
}
/**/
} catch (Exception $e) {
// If we are not allowed to fail, throw back the exception we caught
//.........这里部分代码省略.........
示例6: jimport
/**
* Create a new JException object given the passed arguments
*
* @static
* @param int $level The error level - use any of PHP's own error levels for this: E_ERROR, E_WARNING, E_NOTICE, E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE.
* @param string $code The application-internal error code for this error
* @param string $msg The error message, which may also be shown the user if need be.
* @param mixed $info Optional: Additional error information (usually only developer-relevant information that the user should never see, like a database DSN).
* @return mixed The JException object
* @since 1.5
*
* @see JException
*/
function &raise($level, $code, $msg, $info = null, $backtrace = false)
{
jimport('joomla.error.exception');
// build error object
$exception = new JException($msg, $code, $level, $info, $backtrace);
// see what to do with this kind of error
$handler = JError::getErrorHandling($level);
$function = 'handle' . ucfirst($handler['mode']);
if (is_callable(array('JError', $function))) {
$reference =& JError::$function($exception, isset($handler['options']) ? $handler['options'] : array());
} else {
// This is required to prevent a very unhelpful white-screen-of-death
die('JError::raise -> Static method JError::' . $function . ' does not exist.' . ' Contact a developer to debug' . '<br/><strong>Error was</strong> ' . '<br/>' . $exception->getMessage());
}
//store and return the error
$GLOBALS['_JERROR_STACK'][] =& $reference;
return $reference;
}
示例7: throwError
public static function throwError(&$exception)
{
static $thrown = false;
// If thrown is hit again, we've come back to JError in the middle of throwing another JError, so die!
if ($thrown) {
//echo debug_print_backtrace();
jexit(JText::_('JLIB_ERROR_INFINITE_LOOP'));
}
$thrown = true;
$level = $exception->get('level');
// see what to do with this kind of error
$handler = JError::getErrorHandling($level);
$function = 'handle' . ucfirst($handler['mode']);
if (is_callable(array('JError', $function))) {
$reference = call_user_func_array(array('JError', $function), array(&$exception, isset($handler['options']) ? $handler['options'] : array()));
} else {
// This is required to prevent a very unhelpful white-screen-of-death
jexit('JError::raise -> Static method JError::' . $function . ' does not exist.' . ' Contact a developer to debug' . '<br /><strong>Error was</strong> ' . '<br />' . $exception->getMessage());
}
//we don't need to store the error, since JException already does that for us!
//remove loop check
$thrown = false;
return $reference;
}