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'));
CommentFileSizeAuthor
#2 amfphp.10232008.patch2.13 KBebeyrent

Comments

ebeyrent’s picture

Actually, a more correct implementation would probably be to store the value of the PHP constants:


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, 2039),
    '#options' => array(
      2039 => t('E_ALL ^ E_NOTICE'),
      2047 => t('E_ERROR')
    ),
    '#description' => 'Configure the PHP error types for which AMFPHP will throw exceptions'
  );
  return system_settings_form($form);
}

And this is how the gateway error handling would be set:

$gateway->setErrorHandling(variable_get(AMFPHP_EXCEPTION_HANDLER, 2039));
ebeyrent’s picture

Status: Active » Needs review
StatusFileSize
new2.13 KB

And here's a patch comprised of the above code.

snelson’s picture

Category: support » feature
Status: Needs review » Fixed

Committed to D5 and D6 dev branches. See admin/build/services/settings/amfphp.

Thanks guys!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.