Project:
UbercartCategory:
bug reportPriority:
normalStatus:
activewhen I clear my cart, I'm getting this consistently now:
warning: strpos() [function.strpos]: Offset not contained in string. in /home/cha0s/www/drupe_6/sites/all/modules/ubercart/uc_product/uc_product.module on line 1184.



Re: Error when clearing cart
I was getting that, too... a recent update by Lyle simply took that code all the way out. It should be there if you bzr update.
Re: Re: Error when clearing cart
Seems it's still there, even after a bzr update.
Yep
I also was getting this same error—both when proceeding to checkout, and if updating the cart when viewing it. Refreshing the page eliminated the error.
Viewing the code at line 1184, all it is doing was checking if the word "cart" was in the requesting URI, and if not, it would report "Your item(s) have been updated." Presumably, this is for updates that occur through a cart block on the sidebar of another part of the site or similar.
Anyway, looking into the syntax of strpos, the offset can only be a positive integer, not the -4 that is trying to be used to start at the end of the URI. Therefore, the following modification eliminates the error:
if (!strpos(request_uri(), 'cart')) {drupal_set_message(t('Your item(s) have been updated.'));
}
In other words, just delete the optional offset parameter from the strpos function. Whether this displays the desired behaviour could be queried—there may be some scenarios where you are on a page that has the string "cart" in the URI (even in the name of a product) and this status update would then fail to display. Not a big loss, however, and at least it eliminates the error messages.
Re: Yep
That code'll work, however I wonder if the cart string should only be found on the end of the string. If so, this code would be better:
if (substr(request_uri(), -4) !== 'cart') {Re: Re: Yep
I've decided that the update message never actually needs to be shown, so I've taken out the whole section of code. It'll certainly be easier to maintain that way.