$order and order's products order property are supposed to point to the same order object:

<?php
foreach ($order->products as $product) {
  drupal_set_message($product->order === $order);
}
?>

should display only "1".

But sometimes it's not the case especially when reviving products.
I need more checks to narrow down the problem.

Members fund testing for the Drupal project. Drupal Association Learn more

Comments

anrikun created an issue. See original summary.

TR’s picture

Status: Active » Closed (won't fix)

http://php.net/manual/en/language.oop5.object-comparison.php

When using the comparison operator (==), object variables are compared in a simple manner, namely: Two object instances are equal if they have the same attributes and values (values are compared with ==), and are instances of the same class.

When using the identity operator (===), object variables are identical if and only if they refer to the same instance of the same class.

There is no guarantee here that the two order objects are the same instance, so === isn't appropriate. But I think == won't work with circular references.

I don't think there's much we can do here, given Drupal 7's lack of an object model and PHP's jerry-built object model. I suggest comparing on $order->order_id, as the order number is a unique identifier for the order in the DB.

If you think that this issue results in errors or bugs in Ubercart, please detail the symptoms of the problem so we can try to find a workaround.

anrikun’s picture

Status: Closed (won't fix) » Needs review
FileSize
542 bytes

This issue does not result in bugs in Ubercart itself as the order property of products is used nowhere.
But as this property exists, let's make it work.
It's completely feasible like in Views for instance where all sub-objects keep a reference to their view.
I think I found where the bug is and this simple patch fixed it for me.