Closed (fixed)
Project:
Commerce Core
Version:
7.x-1.x-dev
Component:
Line item
Priority:
Normal
Category:
Bug report
Assigned:
Issue tags:
Reporter:
Created:
14 Oct 2010 at 10:09 UTC
Updated:
3 Jan 2014 at 02:04 UTC
Jump to comment: Most recent
Comments
Comment #1
rszrama commentedHmm... thanks for the report, and this will be a tough issue. ; )
Well, not tough, but not trivial. Right now there's no good way to accomplish general access control, because there is no uid field on line items. However, even if there were, it wouldn't accomplish access control for anonymous users. The problem there is Line Item doesn't have a dependency on Cart, which is the only module that relates an order to an anonymous user. Will have to think this through, especially in conjunction with #927090: Revamp / unify entity access.
Comment #2
redben commentedShouldn't line_item access be implicitly inherited from the order ? is there a use case where you have to load line items without the order ?
Comment #3
rszrama commentedNope, but we kept them separate in case line items would be attached to something else - a packing slip perhaps. : ?
So, yes, access should be implicitly inherited from the order, but we don't have any way to determine what order a line item belongs to if all we have is the line item object. If we have the line item object and the field that references it, we can perform an access check with the necessary data... so I'll be thinking in that direction.
Comment #4
das-peter commentedMaybe a similar issue:
commerce_payment_transaction_accessis also declared as callback but not implemented yetComment #5
rszrama commentedheh, whoops. The good thing about that one is payment transactions have an order_id baked in, so that'll be easy enough to put in place. : )
Comment #6
rszrama commentedHey Peter, I went ahead and committed the full payment transaction access function / implementation.
Commit: http://github.com/rszrama/drupalcommerce/commit/db604c07984b4c7ebbe30e38...
Comment #7
mrfelton commentedThis one just hit me whilst trying to use Rules to create a Product Entity on node creation.
Comment #8
das-peter commented@mrfelton: I've just commented out the declaration of the callback.
@rszrama: What do you think about commenting out this line and add a TODO tag? Not a solution, but at least this wouldn't be a "showstopper" anymore.
Comment #9
pieterdcGood suggestion IMO
Comment #10
mrfelton commentedI just added a callback function that returns TRUE to get around the issue for now.
Comment #11
pieterdcThat's what I did on my local version too ;-)
Comment #12
rszrama commentedSorry, I thought I had implemented a temporary fix back when this was first reported. I just put in a shell function with a TODO item as suggested above. Will have to get on this one soon. : )
Commit: https://github.com/rszrama/drupalcommerce/commit/8047cd195d7c0d0c8982879...
Comment #13
redben commentedOk :
- a line item could be referenced by any entity, not just an order
- a line item being loaded "standalone" doesn't seem to make sense (may be i'm wrong ?)
- there (seems) to be no way to know which referencing entity the line item is being loaded for
So what about having access to line items always set at the level of the referencing field ?
Comment #14
rszrama commentedNow that line items contain an order_id property, access to line items should simply work through the order access function if an order_id is available.
Comment #15
rszrama commentedAlrighty, I made commerce_line_item_access() extensible and have the Order module granting update / delete access to line items on orders the user has permission to update.
https://github.com/rszrama/drupalcommerce/commit/593688973394de683c6495a...