Strict warning: Creating default object from empty value in uc_coupon_load() (line 13 of /sites/all/modules/uc_coupon/uc_coupon.entity.inc).
function uc_coupon_load($cid) {
$coupon = db_query("SELECT * FROM {uc_coupons} WHERE cid = :cid", array(':cid' => $cid))->fetchObject();
$coupon->data = isset($coupon->data) ? unserialize($coupon->data) : array();
should be replaced with the following .
function uc_coupon_load($cid) {
$coupon = db_query("SELECT * FROM {uc_coupons} WHERE cid = :cid", array(':cid' => $cid))->fetchObject();
// check whether data is really fetched and $coupon is not NULL.
$coupon = is_Object($coupon)? $coupon : new stdClass();
$coupon->data = isset($coupon->data) ? unserialize($coupon->data) : array();
Comments
Comment #1
rickmanelius commentedAttaching a patch from the issue summary (I can confirm that it works, but need someone else to review).
Comment #2
rickmanelius commentedHi @amar.deokar,
Can you check real quick so we can mark this one line patch as RBTC?
-Rick
Comment #3
wodenx commentedThis looks fine to me. Committed. Thanks both for the patch.
Comment #4
amar.deokar commentedThanks guys !
Comment #5.0
(not verified) commentedcomment was corrected in code tag.
Comment #6
swatchion commentedthank you, this patch works like a charm.
Comment #7
GARONNE Bruno commentedThank guys !
Your patch work ;)
Comment #8
jackalope commentedThe same problem exists in the 6.x-1.7 version of uc_coupon, but the fix in the patch for Drupal 7 works for Drupal 6, too. I've attached a patch for D6 in case anyone needs it!
Comment #9
matt.rad commentedI get this error when I enable the Discount Coupon Purchase submodule, using 7.x-2.1-alpha7, but not otherwise. Will this patch be rolled into a version of the module for release?
Comment #10
drupalove commentedComment #11
DrCord commentedThis patch seems to work fine for the site I admin that it is running on .