Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
* Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 178 of C:\xampp\htdocs\drupal\includes\entity.inc).
* Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->cacheGet() (line 354 of C:\xampp\htdocs\drupal\includes\entity.inc).
* Recoverable fatal error: Object of class stdClass could not be converted to string in DatabaseStatementBase->execute() (line 2039 of C:\xampp\htdocs\drupal\includes\database\database.inc).
Look attachment
Comment | File | Size | Author |
---|---|---|---|
#29 | 1022736-validate-order-id-arg-2.patch | 4.14 KB | Pedro Lozano |
#27 | 1022736-validate-order-id-arg.patch | 1.45 KB | Pedro Lozano |
#6 | 01 - add to cart.png | 26.27 KB | alexpua |
08 - result.png | 29.3 KB | alexpua | |
07 - click - add to cart.png | 30.54 KB | alexpua |
Comments
Comment #1
Damien Tournoud CreditAttribution: Damien Tournoud commentedComment #2
PieterDCWhich version of the Views module are you using?
Are you using the latest dev version of the Views module? ... as mentioned in #1012888: Error adding products to a order in cart status
Comment #3
alexpua CreditAttribution: alexpua commentedViews 7.x-3.0-alpha1
Drupal 7.0
Comment #4
alexpua CreditAttribution: alexpua commentedComment #5
PieterDCCould you try updating your Views module to 7.x-3.x-dev
and report if that fixes your problem?
Comment #6
alexpua CreditAttribution: alexpua commentedProblem did not fixed
I have tried two combination:
- drupal 7.0 + Views 7.x-3.x-dev
- drupal 7.x-dev + Views 7.x-3.x-dev
result is same, look attach
Comment #7
HazaHad the same error here.
Using lastest dev release of commerce and views seems to fix it.
Comment #8
rszrama CreditAttribution: rszrama commentedHmm, those errors could have been a Views bug in alpha1 that was fixed, but they also come from the Entity module. That's what causes the problems for me when I get them, anyways... has to do with an invalid load request using objects instead of IDs.
It looks like your problem may stem from not having the proper version of Drupal Commerce's dependent modules. Per the installation instructions on the project page, you need to use the dev versions of all the dependencies. e.g. Views 3.x-dev, Entity 1.x-dev, Rules 2.x-dev. Update all your dependencies and try again, and then if it still doesn't work I'll need you to attempt an installation with the Commerce Dev installation profile - that's what I use to build test sites, and I don't get any problems on Add to Cart atm.
Comment #9
alexpua CreditAttribution: alexpua commentedFirst change core and views:
-Views 7.x-3.x-dev
-Drupal 7.x-dev
but the error remained
After change Entity API from 7.x-1.0-beta6 to 7.x-1.x-dev bug fixed
Thank you!!!
Comment #10
PieterDCYou're welcome
Comment #11
rszrama CreditAttribution: rszrama commentedExcellent. Always check the installation instructions on the project page, as I keep them up to date with the current working versions of dependencies for either our latest point release or the current dev release.
Comment #12
thersitz CreditAttribution: thersitz commentedJust loaded drupal 7 -- upgraded from a fresh 6.20 install on my host. When I select add content I get this error. I have views installed but do not have commerce or entity api installed. A minute ago I attempted to add content again and the error did not appear. So in a matter of minutes it appeared and then did not.
Comment #13
Bèrto ëd Sèra CreditAttribution: Bèrto ëd Sèra commentedI confirm the error and I also confirm that installing from the commerce profile and using the master modules from git solves all problems (possibly time to make a new alpha release for those using the modules from the drupal site, though)
Comment #15
sun-fire CreditAttribution: sun-fire commentedThe same warning messages with:
Core: 7.9
Commerce: 7.x-1.0
Views: 7.x-3.0-rc1
Entity API: 7.x-1.0-rc1
When i try to execute this code:
I recieve the list of warnings:
for each line item. (For examle, I receive 4 warnings for two different products in the cart).
When the cart is empty the same code return results with no warnings.
Comment #16
khiminrm CreditAttribution: khiminrm commentedsubscribe
Comment #17
rszrama CreditAttribution: rszrama commentedDo you get the error on 1.x-dev? There have been almost 90 commits since 1.0, so this may have been fixed since then. I haven't done any complete testing w/ Entity API 1.0-rc1, but I wouldn't expect there to be a break between then and now.
Comment #18
sun-fire CreditAttribution: sun-fire commentedI get the same error for the latest dev version of commerce.
Comment #19
rszrama CreditAttribution: rszrama commentedAre you using any contributed modules in addition to Commerce?
Comment #20
tscadfx CreditAttribution: tscadfx commentedI'm getting the same error as well with Commerce Custom Line Items in use.
Comment #21
rszrama CreditAttribution: rszrama commentedDo you get the same error without that module in use? Someone needs to help narrow this down, so feel free to post some research so I don't have to keep asking follow-up questions. : D
Comment #22
MurzI have the same problem, I use commerce dev version, commerce_stock 2.x, commerce_shipping 2.x.
I debug the problem and find that in includes/entity.inc line 177 Drupal try to do array_flip of
array ( 0 => array ( 'product_id' => '6', ), )
Comment #23
MurzI have found the problem and solve for me: I use function
but this is wrong, I change it to
$order = commerce_order_new(0, 'pending');
and warning go away.Comment #24
rszrama CreditAttribution: rszrama commentedAhh, nice. Where was that code located? That definitely needs to be fixed, as NULL is not a valid uid but 0 is (for the anonymous user).
Comment #25
MurzThis code is in my module, I do the wrong function call, module works normally.
Comment #26
rszrama CreditAttribution: rszrama commentedI gotcha. Maybe it's something we can look out for in other modules or Rules then.
Comment #27
Pedro Lozano CreditAttribution: Pedro Lozano commentedThis can be fixed by adding a validation criteria to the "Order ID" argument of the "Shopping cart form" view to check that the argument is numeric.
The problem happens when you create a block using this view to display the cart and you change the contextual filter to have a default value to the current users' order id.
The default argument handler returns FALSE if the user still doesn't have an order in the commerce_order table.
By adding a validation setting to make sure it is numeric we avoid a call to entity_load('commerce_order', array(FALSE)) and we keep this warning from appearing.
Comment #28
Pedro Lozano CreditAttribution: Pedro Lozano commentedComment #29
Pedro Lozano CreditAttribution: Pedro Lozano commentedAdded the same fix to other views that need it.
Comment #30
DamienMcKennaLooks good, anyone else to review it so we can make this RTBC?
Comment #31
Umayal CreditAttribution: Umayal commentedI used
Core: 7.10
Views: 7.x-3.0-rc1
Entity API: 7.x-1.0-rc1
and
Core: 7.10
Views: 7.x-3.x-dev
Entity API: 7.x-3.x-dev
When i load the user,I get same error.
Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 178 of /......./includes/entity.inc).
Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->cacheGet() (line 354 of /........./includes/entity.inc).
I don't know what is the problem?
Comment #32
Pedro Lozano CreditAttribution: Pedro Lozano commentedComment #33
Umayal CreditAttribution: Umayal commentedI removed flip error
It's my code problem not module or core versions.
Comment #34
HazaPlease keep the title.
Comment #35
rszrama CreditAttribution: rszrama commentedTagging.
Comment #36
helior CreditAttribution: helior commentedSigh. I'm having a really hard time replicating this issue. I basically keep following Pedro's steps from #27, but to no avail. Has anyone been able to reproduce this on a fresh install of Drupal Commerce? The patch is about 3 months old, so maybe there's a chance that the underlying problem has been fixed by a previous commit. If someone can leave some steps to reproduce on a fresh install of Commerce, I'll be happy to review it so we can get this committed in the next point release.
Comment #37
Murzhelior, you can reproduce this error via creating new order via API with Order ID = NULL (not 0).
Comment #38
rszrama CreditAttribution: rszrama commentedOk, I was able to reproduce it by clearing out my cart order, adding a page display to the cart form View, and updating the Order ID argument to provide a default value using the user's current cart order ID. Visiting the path for the View results in the error, because the argument was returning a FALSE when no order ID was found, which is invalid for commerce_order_load(). Instead of the fix suggested above, I've patched the handler to return an explicit 0 instead of FALSE if it cannot find a current cart order ID. Because that appears to fix the issue at a closer level than Views configuration, I'm going to go ahead and mark this fixed.
However, in my testing, I turned up a little disturbing discovery. Basically, because we're depending on a contextual filter, I don't see any way to not allow users to throw in any random order ID they want to try in that form. And then if they have access to the order - such as an order they just placed - they'd be able to update its contents. Granted, using the shopping cart form to update its contents would then remove it from the pending / complete orders list and make it a shopping cart again, but it's still a hack (albeit a silly one, because now you've paid money and won't get your product).
I'm wondering, does anyone who's using this have a strategy to prevent people from adding an Order ID to the URL? What I mean is, if I add a page View to the shopping cart form at /my-cart and update the argument like I said above (to validate using the current cart order ID in the absence of a URL provided argument), how can I prevent the URL /my-cart/123 from showing the shopping cart form for order 123.
Also, testing shows me that even though we determined we should implement #1030128: Convert shopping cart block and form Views to use Views block / page displays in a contrib module, we should still put into core the form altering that prevents buttons from showing on an empty shopping cart form. Otherwise even though a user may not be able to see the line items on other peoples' orders, they could still submit the form and potentially jack up their order statuses.
Comment #39
rszrama CreditAttribution: rszrama commentedAnd wow, this issue has been open for 16 months! Glad it's closed now. : )
Commit: http://drupalcode.org/project/commerce.git/commitdiff/8ba3ecc
Comment #41
MGParisi CreditAttribution: MGParisi commentedJust got it when running CRON, Not the exact error, but the same line number on the first warning
Comment #42
rszrama CreditAttribution: rszrama commentedAre you sure you're having the same issue? This issue is for the error as produced by a Views argument handler, and unless you aren't running Commerce 1.3 I don't know how you can still be getting it.
Comment #43
ljgra CreditAttribution: ljgra commentedUsed the patch, problem still on (even if this post was years ago)...