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

rickmanelius’s picture

Status: Active » Needs review
StatusFileSize
new524 bytes

Attaching a patch from the issue summary (I can confirm that it works, but need someone else to review).

rickmanelius’s picture

Hi @amar.deokar,

Can you check real quick so we can mark this one line patch as RBTC?

-Rick

wodenx’s picture

Status: Needs review » Fixed

This looks fine to me. Committed. Thanks both for the patch.

amar.deokar’s picture

Thanks guys !

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

comment was corrected in code tag.

swatchion’s picture

thank you, this patch works like a charm.

GARONNE Bruno’s picture

Thank guys !
Your patch work ;)

jackalope’s picture

Issue summary: View changes
StatusFileSize
new651 bytes

The 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!

matt.rad’s picture

I 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?

drupalove’s picture

Issue summary: View changes
DrCord’s picture

This patch seems to work fine for the site I admin that it is running on .