When an anonymous user tries to add a product to his shopping cart, a PDOException occurs. Here is the actual error message:

PDOException: SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for integer: "5a1517558180de423e23eb37d570a38f" LINE 4: WHERE (base.uid IN ('5a1517558180de423e23eb37d570a38f')) ^: SELECT base.uid AS uid, base.name AS name, base.pass AS pass, base.mail AS mail, base.theme AS theme, base.signature AS signature, base.signature_format AS signature_format, base.created AS created, base.access AS access, base.login AS login, base.status AS status, base.timezone AS timezone, base.language AS language, base.picture AS picture, base.init AS init, base.data AS data FROM {users} base WHERE (base.uid IN (:db_condition_placeholder_0)) ; Array ( [:db_condition_placeholder_0] => 5a1517558180de423e23eb37d570a38f ) in DrupalDefaultEntityController->load() (line 196 of /var/websites/zzzzzzzzzzzzzz/htdocs/includes/entity.inc).

PostgreSQL cannot cast the session hash string to an integer and generates a PDOException. I am attaching a patch which fixes the issue. It is not tested thoroughly but seems to work.

Comments

stano.lacko’s picture

Thanks for this patch, I can prove, that it's working on PostgreSQL

SilviuChingaru’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, ubercart.anonymous_cart.patch, failed testing.

longwave’s picture

Version: 7.x-3.0 » 7.x-3.x-dev
Status: Needs work » Needs review
StatusFileSize
new868 bytes

Please test this patch.

longwave’s picture

StatusFileSize
new954 bytes

Actually, this should be more reliable, as it uses the same test as uc_cart_cron(). ctype_digit() and preg_match() may give false positives in a small number of cases.

tr’s picture

Status: Needs review » Needs work

22? At the *very* least, that deserves a line or two of comments.

longwave’s picture

Status: Needs work » Needs review
StatusFileSize
new3.52 KB

This patch reworks the UcOrder constructor entirely, adding a docblock and removing duplicated code.

longwave’s picture

Status: Needs review » Fixed

Committed #7.

Status: Fixed » Closed (fixed)

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

liezie_d’s picture

Dear,

I encountered the same error as the original poster.
I applied the last patch in this thread. Anonymous users are now able to send items to the cart and view the cart.
However, when I press the "remove" button on one of the items, i get the error:
Fatal error: Cannot use [] for reading in C:\inetpub\drupal-7.12\modules\taxonomy\taxonomy.module on line 215

Second question: will this patch be part of the next version release, or do we need to patch with each uc upgrade?

liezie_d’s picture

Status: Closed (fixed) » Needs work
liezie_d’s picture

Status: Needs work » Closed (fixed)

i've been able to resolve the taxonomy error by emptying the cart and clearing the cache.