backdrop-contrib / shopify

Integrate and sync your site with a Shopify store.
GNU General Public License v2.0
0 stars 1 forks source link

Products tab isn't showing (Entity UI) #21

Closed laryn closed 2 years ago

laryn commented 2 years ago

In D7 there is a "Products" tab on the admin/shopify page. It isn't showing in Backdrop currently.

laryn commented 2 years ago

Trying to view the path admin/shopify/products/ gives Access Denied (even for user 1).

laryn commented 2 years ago

This path is referenced in shopify_menu_alter

Also in shopify_entity_info

laryn commented 2 years ago

Screen Shot 2022-04-12 at 5 37 04 PM

argiepiano commented 2 years ago

I believe the issue is that ShopifyProductsUIController extends a custom class called ShopifyEntityDefaultUIController that closely resembles EntityDefaultUIController (which is defined by Entity UI). @laryn, you probably created ShopifyEntityDefaultUIController based on D7 Entity API? This custom class is making use of entity_access in the menu definitions - which is problematic given that Backdrop's entity_access is not the same as D7 Entity API entity_access.

It may be best to extend EntityDefaultUIController, since Entity UI is a required module for Shopify anyways.

OR you can modify ShopifyEntityDefaultUIController and change entity_access by entity_ui_access or entity_plus_access, or a custom function specifically written for Shopify. The issue with entity_access is that it's a function now provided in core, and it's substantially different from the old one in D7 Entity API - and this is the reason you are getting access denied and not seeing that tab in the configuration pages.

If you decide to get rid of ShopifyEntityDefaultUIController and instead extend EntityDefaultUIController, one caveat: Entity UI is poorly maintained, and the access callbacks are mostly dummy functions that always return TRUE, meaning that everyone with access to the Admin Bar will see admin links to stuff like configuring entity types.

I recently became a maintainer of Entity UI and I have a PR that was never reviewed or merged, which takes care of correctly checking for access. I need to go back and review that PR to see if it looks OK, then merge it and do a new release of Entity UI. I've run into this access check issues in several situations (e.g. what I mentioned about, where configuration menu options are shown to everyone with access to the Administration Bar).

laryn commented 2 years ago

Thanks @argiepiano that is helpful. I am adding a commit that moves things around slightly (moving ShopifyProductsUIController into shopify.entity.ui.inc) and modifies ShopifyEntityDefaultUIController (to use entity_plus_access and to extend EntityDefaultUIController) and also cleans out a few of those bats that flew out of the attic (more _plus_ issues, for example).