function commerce_line_item_entity_info()
defines
'access callback' => 'commerce_line_item_access'
but
function commerce_line_item_access()
isn't defined.

Comments

rszrama’s picture

Hmm... 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.

redben’s picture

Shouldn'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 ?

rszrama’s picture

Nope, 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.

das-peter’s picture

Maybe a similar issue: commerce_payment_transaction_access is also declared as callback but not implemented yet

rszrama’s picture

heh, 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. : )

rszrama’s picture

Hey Peter, I went ahead and committed the full payment transaction access function / implementation.

Commit: http://github.com/rszrama/drupalcommerce/commit/db604c07984b4c7ebbe30e38...

mrfelton’s picture

This one just hit me whilst trying to use Rules to create a Product Entity on node creation.

das-peter’s picture

@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.

pieterdc’s picture

Good suggestion IMO

mrfelton’s picture

I just added a callback function that returns TRUE to get around the issue for now.

pieterdc’s picture

That's what I did on my local version too ;-)

rszrama’s picture

Sorry, 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...

redben’s picture

Ok :
- 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 ?

rszrama’s picture

Version: 7.x-1.0-alpha2 » 7.x-1.x-dev
Assigned: Unassigned » rszrama
Issue tags: +beta blocker

Now 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.

rszrama’s picture

Status: Active » Fixed

Alrighty, 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...

Status: Fixed » Closed (fixed)
Issue tags: -beta blocker

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