Had same error with Ubercart 3.0. Upgraded to 3.1 thinking it would solve it as lots of 3.1 fixes, but it didn't.

Error went from line 399 to line 400 is all.

I tried to use the clone button with a custom tax rate but it crashed with a screen full of errors (record attempted to clone was uc_taxes_32 and clone was uc_taxes_33:

> Notice: Undefined property: RulesAnd::$id in drupal_write_record() (line 6831 of //includes/common.inc).

> Notice: serialize() [function.serialize]: "id" returned as member variable from __sleep() but does not exist in DrupalDatabaseCache->set() (line 418 of //includes/cache.inc).

> Notice: serialize() [function.serialize]: "id" returned as member variable from __sleep() but does not exist in drupal_write_record() (line 6834 of //includes/common.inc).

> PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'uc_taxes_33' for key 'name': INSERT INTO {rules_config} (name, label, plugin, active, weight, status, dirty, module, data) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8); Array ( [:db_insert_placeholder_0] => uc_taxes_33 [:db_insert_placeholder_1] => DDC Fee (products) conditions [:db_insert_placeholder_2] => and [:db_insert_placeholder_3] => 1 [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => 3 [:db_insert_placeholder_6] => 0 [:db_insert_placeholder_7] => uc_taxes [:db_insert_placeholder_8] => O:8:"RulesAnd":13:{s:9:"*parent";N;s:2:"id";N;s:12:"*elementId";i:1;s:6:"weight";s:1:"0";s:8:"settings";a:0:{}s:4:"name";s:11:"uc_taxes_33";s:6:"module";s:8:"uc_taxes";s:6:"status";i:3;s:5:"label";s:29:"DDC Fee (products) conditions";s:4:"tags";a:0:{}s:11:"*children";a:1:{i:0;O:14:"RulesCondition":7:{s:9:"*parent";r:1;s:2:"id";N;s:12:"*elementId";N;s:6:"weight";i:0;s:8:"settings";a:3:{s:11:"data:select";s:17:"order:order-total";s:2:"op";s:2:"==";s:5:"value";s:4:"0.01";}s:14:"*elementName";s:7:"data_is";s:9:"*negate";b:0;}}s:7:"*info";a:1:{s:9:"variables";a:1:{s:5:"order";a:2:{s:4:"type";s:8:"uc_order";s:5:"label";s:5:"Order";}}}s:9:"*negate";b:0;} ) in drupal_write_record() (line 6888 of //includes/common.inc).

Read about clearing out rules and cache. Did that. Still getting error in title of this report.

I'm still on Drupal 7.10. Wondered if it was to do with needing latest version? Or maybe another module needing update? Been busy with site development so not updated a few modules. Or maybe not related to this?

Any thoughts?

Many thanks

CommentFileSizeAuthor
#14 1565822-uc_taxes-D5-compat.patch667 byteslongwave

Comments

tr’s picture

Priority: Critical » Normal
Status: Active » Postponed (maintainer needs more info)

This appears to be a bug in Rules/Entity API. I was able to reproduce the error, but it went away after I upgraded to the latest dev versions of Rules and Entity API. Please try that on your site and report whether it eliminates the error for you.

den33775’s picture

Many thanks. Unfortunately, that didn't solve it for me, even after remembering to run update.php after module updates. :o( And I updated to latest dev version of ubercart after 3.1 didn't fix.

I did notice that the cloned (and some deleted) rules in rules_config mysql table were still there, referring to now non-existant tax IDs in uc_taxes table. I deleted the obsolete rules records manually with phpmyadmin 3 to tidy up. Did this before your reply, hoping it wwould fix problem (it didn't), so don't know if upgrades you mention would have tidied up for me or not. Maybe you could check your mysql tables/records and reply, for others, so they know if manual tidy-up is necessary on rules_config records, in addition to rules and entityAPI updates. For others reading this, in future, the relevant record names are obvious - puts tax ID on end of field content as underscore then the ID number (e.g."uc_tax_33" in this case, ref's uc_tax_config table with record indexed by tax ID number 33). If there are any other tidy-ups needed that I've missed, pls reply - I couldn't see anything else relevant in the rules table. I don't think these manual deletions would have affected the fix as the records were orphans/widows. ??

I could try to cure symptom by deleting all tax rules and starting again, but is a lot of re-work if this doesn't work, plus would be nice to resolve properly for our fellow drupal users.

Any more thoughts? Are there any screen prints it would be helpful for me to provide?

Best wishes

den33775’s picture

Priority: Normal » Major

UPDATE:

I finally got around to downloading a PHP editor so I could find the line numbers!

The error occurs in the section of code:

// For orders no longer in checkout, only the saved tax rates can apply.
elseif (isset($order->order_status) && uc_order_status_data($order->order_status, 'state') != 'in_checkout') {
if (isset($order->line_items)) {
foreach ($order->line_items as $item) {
if ($item['type'] == 'tax') {
if (!empty($item['data']['tax'])) {
// Use the rate stored in the line-item.
$taxes[] = clone $item['data']['tax'];
}
elseif ($tax = uc_taxes_rate_load($item['data']['tax_id'])) {
// For old orders that don't have all the tax info, all we can do
// is preserve the rate.
$tax = clone $tax;
if (!empty($item['data']['tax_rate'])) {
$tax->rate = $item['data']['tax_rate'];
}
$taxes[] = $tax;
}
}
}
}
}

So, I figured it was related to a reference to a tax rate related to the original bug (which I'd fixed in theory by downloading latest rules and entity api modules). The offending tax rate being referenced in old orders.

I went to my ubercart orders list and found a massive number of recurring payments related to the order. Attachment payments.jpg shows the next recurring fee was order number 686, but attachment 'recurring error.jpg' shows order 685 was in fact the next created recurring fee and that it creates 687 through to order 1711 at which time (just now) I cancelled the recurring payments (see 'cancel error.jpg'). As you will see, on cancelling the rogue recurring payment that had appeared out of nowhere (no recurring fee set on product - it was recurring minute by minute forever), I got another error (notice: undefined index: cancel callback in uc_recurring_invoke() (line 732 of //modules/uc_recurring//uc_recurring.module).

I then went back to the UC orders list to do some of the attached screen shots and when I returned to the user's recurring fees page, the error had gone (a one time only error then?) - see 'cancel error now gone.jpg'.

As to what caused this, I had set up thirty tax rules, all with 'order total' being checked between two amounts (i.e. using condition 'lower than', then an 'AND', then another condition on the AND 'greater than', to add the tax only if the order total was between two values. All other orders seemed to work. Not sure this is related, but only other thing I can think of is I had added a new field to a content type that was associated with an Organic Group, and I had forgotten to go into OG fields permissions to give the OG administrator access to that field. This cause various errors that it took me a bit of diagnosing to track down. All were cleared, but the lack of access to a single field during processing seemed to cause all sorts of my drupal modules a headache. Maybe this inaccessible field in a product caused the UC tax module to trip a recurring fee when it shouldn't have? That's all I can think of for now. I am deleting all the hundreds of orders created by this error and expect the problem to go away when I'm done.

I would recommend some kind of check added to UC to ensure there really is a recurring fee set up on a product before adding thousands of them! :)

Will add more if I find out any thing relevant, but if anyone knows if I can delete orders a bit quicker, in blocks, would appreciate the tip!

Best wishes all

The original order was for a product type that did not have recurring payments set up on it (i.e. features tab had no recurring payments on it and it wasn't a product that would have such recurring fees anyway).

den33775’s picture

p.s. in the code snipped, the actual line causing the error is, of course "$taxes[] = clone $item['data']['tax'];"

den33775’s picture

replied as 2 and 3 - forgot to hit reply button. Not sure if it notifies you of my comments unless I hit the reply to yours, so hence this msg. :)

den33775’s picture

UPDATE: A quick way of stopping all the rogue recurring fees is of course to go to admin/store/orders/recurring as admin and click the cancel button for each record with an interval of zero (0).

This also (for the time being) seems to have stopped the error on line 400 as well, although my order history is now full of hundreds of cancelled recurring orders!

They recur because the interval is zero (recur as fast as your PC/MAC/whatever can process orders!

It is zero because the recurring order appeared by error - i.e. it wasn't set up by a person following any kind of rules, so no actual values entered such as non-zero interval value.

I suggest a safety update would be to edit the php to stop a recurring order (reject it) if the interval is zero.

Had another look at the PHP but sadly my php isn't that good yet and I've not found the relevant code. If I do, before someone that knows what they're doing around ubercart php sorts it out, I'll post my attempt at resolving.

tr’s picture

This is the Ubercart issue queue. uc_recurring is not part of Ubercart. If you have problems with recurring payments you should discuss them in the uc_recurring queue, not here.

den33775’s picture

Ah, thanks, didn't realise it was different module. Will copy comments over there when I get a moment, thanks.

longwave’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

If this is still an issue that can be reproduced without uc_recurring, please reopen with more details.

den33775’s picture

Was uc_recurring. I've switched off the module and all is fine. Was a good idea, but in testing, it billed a 75p download test-customer a little over £20,000! (Very profitable for me, but not sure I'd get many customers!) I believe it was due to a clash with OG's global permissions that controls per-field level access. If the UC customer does not have access to any one field in the UC product, UC Recurring sets up a rogue recurring fee (which was not defined as a feature) with a repeat interval of 0, so it repeats as fast as the processor can repeat it. :S Once I re-set the correct access to the OG product field and cancelled the rogue recurring subscriptions, all was fine until I forgot to go and tick the boxes for the next added field when modifying an UC class/content type and tried to buy something with it! Anyway, detail is already in the UC recurring module issues list for others to see and get help from, as per the good old Drupal tradition!

Best wishes

jerry’s picture

Version: 7.x-3.1 » 7.x-3.4
Status: Closed (cannot reproduce) » Active

Re-opening as suggested as I've just encountered this issue with a site upgraded from D5/UC1 to D7/UC3 (by way of D6/UC2, of course). The error is again in the tax clone operation for older orders. It appears that $item['data'] is FALSE for these orders, so uc_taxes_rate_load() sees the argument $item['data']['tax_id'] as NULL and returns an array, not an object. For the moment, I've worked around the resulting WSOD by changing this test at line 425:

elseif ($tax = uc_taxes_rate_load($item['data']['tax_id'])) {

to:

elseif (($tax = uc_taxes_rate_load($item['data']['tax_id'])) && is_object($tax))

tr’s picture

Priority: Major » Normal
Status: Active » Postponed (maintainer needs more info)

Are you using or have you used uc_recurring on your site?

jerry’s picture

Status: Postponed (maintainer needs more info) » Active

No, uc_recurring is not in use. Someone else built the D5 site, but I saw no evidence that recurring transactions had ever been configured.

longwave’s picture

Status: Active » Needs review
StatusFileSize
new667 bytes

It seems safer to explicitly check $item['data']['tax_id'] before attempting to load it. Can you test the attached patch for me?

Status: Needs review » Needs work

The last submitted patch, 1565822-uc_taxes-D5-compat.patch, failed testing.

longwave’s picture

Version: 7.x-3.4 » 7.x-3.x-dev
Status: Needs work » Needs review
longwave’s picture

#14: 1565822-uc_taxes-D5-compat.patch queued for re-testing.

jerry’s picture

Status: Needs review » Reviewed & tested by the community

Can you test the attached patch for me?

Yes, the patch worked fine here. As there may not be many other folks experiencing this problem available to test it, I'm going to go and and RTBC it - hope that's OK.

Thanks!

longwave’s picture

Status: Reviewed & tested by the community » Fixed

Committed, thanks for testing.

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

See body of message for details of log messages.