After processing an order in Ubercart, when hook_checkout_complete() fires, if the uc_roles module is invoked for role based products, a PHP error is produced in constant_contact.module, line 581:

<?php

	if($category == 'account'):
		$lists = $edit['cc_newsletter_lists'];
	else:
		$lists = $account->cc_newsletter_lists;
	endif;

	$newlists = array();
	foreach($lists as $list_id => $enabled):
		if(intval($enabled) !== 0):
			$list = $cc->get_list($list_id);
			$newlists[$list_id] = $list['Name'];
		endif;
	endforeach;
?>

Running a debug_backtrace showed that when uc_roles implements user_save(), the constant_contact.module's hook_user doesn't pickup on the fact that there's no $edit['cc_newsletters_lists'] and tries passing NULL through the foreach.

A previous bug fix for a similar problem @ line 353 (http://drupal.org/node/697400) doesn't catch this.

Changing @ line 354:

<?php
	if($op == 'insert' || $op == 'after_update'):
	 	if(!isset($edit['cc_newsletter']) && !isset($account->cc_newsletter) && !count($edit['cc_newsletter_lists']) && !count($account->cc_newsletter_lists)):
			return;
		endif;
	endif;
?>

To:

<?php
	if($op == 'insert' || $op == 'after_update'):
	        if ($category == 'account' && !isset($edit['cc_newsletter_lists'])) {
	                 return;
	        }
		if(!isset($edit['cc_newsletter']) && !isset($account->cc_newsletter) && !count($edit['cc_newsletter_lists']) && !count($account->cc_newsletter_lists)):
			return;
		endif;
	endif;
?>

worked for me.
Attached is a patch makes this change, but it needs additional testing to check for other conflicts.

Hope it helps!

CommentFileSizeAuthor
constant_contact.module.patch562 bytesr.aubin

Comments

justphp’s picture

Assigned: Unassigned » justphp
justphp’s picture

Status: Needs review » Closed (fixed)

Fixed it beta2 (releasing in a moment)