When I have a product with an attribute associated with a view for products in a taxonomy and and I finish the checkout everything works.
But when I go to review the content I receive an error for each attribute in the product.
* warning: preg_match() expects parameter 2 to be string, array given in /var/www/html/drupal/includes/bootstrap.inc on line 771.
* warning: preg_match() expects parameter 2 to be string, array given in /var/www/html/drupal/includes/bootstrap.inc on line 771.
* warning: preg_match() expects parameter 2 to be string, array given in /var/www/html/drupal/includes/bootstrap.inc on line 771.
* warning: preg_match() expects parameter 2 to be string, array given in /var/www/html/drupal/includes/bootstrap.inc on line 771.
* warning: preg_match() expects parameter 2 to be string, array given in /var/www/html/drupal/includes/bootstrap.inc on line 771.

Am I not dong something right or is this a bug? Is there a wordkaround or better way to accomplish this?

Thanks in advanced and love the module.

Comments

blagrone’s picture

On further work on this I found it was caused by what I think is some bad code in the bootstrap.inc file.
I posted my solution here:
http://drupal.org/node/225211#comment-1934784

blagrone’s picture

Sorry to keep hijacking my own thread:
Here is an update as I posted this in the Ubercart forums, can anyone help me find where to fix this. I'll keep looking and post answers since I've already talked to a few others who have the same problem.
I'm using node checkout with ads, and everything works great except when it's passed to the order and views I get this error. Also the attributes do not show.
* warning: preg_match() expects parameter 2 to be string, array given in /var/www/html/drupal/includes/bootstrap.inc on line 771.
* warning: preg_match() expects parameter 2 to be string, array given in /var/www/html/drupal/includes/bootstrap.inc on line 771.
* warning: preg_match() expects parameter 2 to be string, array given in /var/www/html/drupal/includes/bootstrap.inc on line 771.
* warning: preg_match() expects parameter 2 to be string, array given in /var/www/html/drupal/includes/bootstrap.inc on line 771.
* warning: preg_match() expects parameter 2 to be string, array given in /var/www/html/drupal/includes/bootstrap.inc on line 771.

The problem it seems to me is that either Ubercart or node checkout is passing an array through the bootstrap.inc utf8 preg_match filters and failing.
I tried editing the filter to implode the array which removed the error, HOWEVER I received a proper lashing on that forum for hacking core.

I get the point, 'NO HACKING CORE' is a rule to be followed, so I'm chasing the error to find what module generates the array. I hope to be able to find where I can implode the error to the string in Ubercart, or if anyone know where I should in node checkout.

Any advice, links?
Thanks and pints in advance.

Ben

wesjones’s picture

I am getting the same message:

warning: preg_match() expects parameter 2 to be string, array given in xxx\includes\bootstrap.inc on line 771.

I have narrowed this issue to UC Node Checkout. It is not handling attributes correctly. I don't see any problems until the order is completed. Once order is completed, whenever I view a node created by uc node checkout that has been purchased, I get the message above.

Attributes are handled a little differently now that checkboxes have been included in ubercart attributes. UC Node Checkout needs updating so it will know how to handle attributes correctly. Patch is not likely from me. Would love to get some help on this.

wesjones’s picture

I think I figured out where the problem lies. In uc_node_checkout.module on line 734 the $options variable turns out to be an array. So I added a foreach loop to cycle through the items in the array.

Before:

foreach ($product->data['attributes'] as $attribute => $option) {
  $option_rows[] = t('@attribute: @option', array('@attribute' => $attribute, '@option' => $option));
}

After:

foreach ($product->data['attributes'] as $attribute => $option) {
  $row_data = t('@attribute: ', array('@attribute' => $attribute));
  foreach ($option as $item) {
    $row_data .= t('@item', array('@item' => $item));
    if (next($option))
      $row_data .= ", ";
  }
  $option_rows[] = $row_data;
}
benstallings’s picture

Status: Active » Reviewed & tested by the community

Thank you for this solution, wesoccer2003! I can confirm that it solves the problem.

codenamerhubarb’s picture

This fixed the problem for me too. Thanks heaps.

echoz’s picture

Fixed it for me too, although a note for those searching, on drupal 6.15 the error is line 777 of bootstrap.inc

matthewn’s picture

Just another "me too" with a thanks for wesoccer2003 for the working solution at #4.

echoz’s picture

As I wrote in #7 I applied the override successfully (in template.php), but I think an issue I have is related, and hoping this fix can be adjusted.

The ul class product-description prints out to the order record + customer email, with one list item for my one option, plus an empty list item. For a product that has no options, it outputs an empty list item. It prints the bullet followed by the colon that would come between the attribute name and the option.

It seems this is produced from function theme_uc_product_attributes, in uc_attribute.admin.inc, but since what I'm seeing is not reported elsewhere, I'm wondering if the code from #4 is causing this. Is anyone who has applied this seeing an empty list item in ul class product-description (in the order record + customer email)?

A list appears correctly with no extra empty bullet on cart, cart/checkout, cart/checkout/review or the cart block.

jeffam’s picture

StatusFileSize
new529 bytes

Hi,

I just bumped into this bug, too, and made my own patch before noticing that there was already an open issue. For what it's worth, here's my fix.

Jeff

echoz’s picture

I tested #10 instead of #4 and no errors, except I still get the same as I described in my #9 post, the extra empty bullet and colon. Viewing the order, the empty bullet proceeds the real attribute: option, and on the invoice, it's after it. Is anyone else getting this, to help debug if this is about uc_node_checkout or unique to something else I'm doing?

qinwubi’s picture

same issue, but #10 fixed mine perfectly. thanks!

echoz’s picture

I figured out my issue in #9 and #11, and is unrelated to the patches offered. It was caused by deleting the defaults in the fields of the last item in uc_node_checkout settings, even though checkbox "Add to the default node cart teaser using these settings" is unchecked. I think this is a bug, I'll open its own issue.

pkiff’s picture

Patch #10 fixed the described problem on my install also (Drupal 6.16, UC Node Checkout 6.x-2.0-beta4, IIS 7).

Thanks!

Phil.

nathanjo’s picture

Confirmed this is a bug.

#10 patch just works fine.

bisonbleu’s picture

StatusFileSize
new11.11 KB
new11.5 KB

Applied patch in #10.
And Alleluia brothers & sisters! :-)
This one has been nagging me for months.

Nodes created by uc_node_checkout were showing "Original product attributes" as empty.
The attribute is back & properly displayed.

Bravo!

tchurch’s picture

I have also tested #10 (manually updated my module file as not in position to run a patch from where I am currently) and it worked.

This also fixes my issues #851084: Product attributes cause errors and #900336: htmlspecialchars error (which I will now close).

When will this be added to a new version (-dev or otherwise)?

baff’s picture

#10 removed warning "html special character ..." and in addition attribute options are showing up now on node view -thank you jeffam

aidanlis’s picture

aidanlis’s picture

Status: Reviewed & tested by the community » Fixed

Fixed: Commit 46f89cc on 6.x-2.x

Status: Fixed » Closed (fixed)

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