I've been working with Flex, AMFPHP, and Services, and came across a case where AMFPHP was throwing a fault on a PHP warning message:
imagecolorsforindex(): Color index 108 out of range
I found that simply changing the gateway error handling to this:
//$gateway->setErrorHandling(E_ALL ^ E_NOTICE);
$gateway->setErrorHandling(E_ERROR);
Everything works as expected. Should faults get thrown on warnings? Could we just add an admin interface:
define(AMFPHP_EXCEPTION_HANDLER, 'amfphp_exception_handler');
/**
* implementation of hook_menu
*/
function amfphp_menu($may_cache){
$items = array();
if($may_cache){
$items[] = array(
'path' => 'admin/settings/amfphp/exceptions',
'title' => t('AMFPHP Exceptions Configuration'),
'callback' => 'drupal_get_form',
'callback arguments' => array('amfphp_admin'),
'description' => t('AMFPHP Exception handling configuration'),
'access' => user_access('administer site configuration')
);
}
return $items;
}
function amfphp_admin(){
$form = array();
$form['amfphp'] = array(
'#type' => 'fieldset',
'#title' => t('AMFPHP Exception Settings'),
'#collapsible' => FALSE,
'#collapsed' => FALSE,
'#weight' => -4,
);
$form['amfphp'][AMFPHP_EXCEPTION_HANDLER] = array(
'#type' => 'select',
'#title' => t('Select PHP error threshold'),
'#default_value' => variable_get(AMFPHP_EXCEPTION_HANDLER, 'E_ALL ^ E_NOTICE'),
'#options' => array(
'E_ALL ^ E_NOTICE' => t('E_ALL ^ E_NOTICE'),
'E_ERROR' => t('E_ERROR')
),
'#help' => 'Configure the PHP error types for which AMFPHP will throw exceptions'
);
return system_settings_form($form);
}
And then in amfphp.module, you could do something like:
$gateway->setErrorHandling(variable_get(AMFPHP_EXCEPTION_HANDLER, 'E_ALL ^ E_NOTICE'));
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | amfphp.10232008.patch | 2.13 KB | ebeyrent |
Comments
Comment #1
ebeyrent commentedActually, a more correct implementation would probably be to store the value of the PHP constants:
And this is how the gateway error handling would be set:
Comment #2
ebeyrent commentedAnd here's a patch comprised of the above code.
Comment #3
snelson commentedCommitted to D5 and D6 dev branches. See admin/build/services/settings/amfphp.
Thanks guys!