First of all, very useful module, thanks.

Problem/Motivation

For instance \Drupal\base_field_override_ui\Controller\BaseFieldOverrideController::addAccess function always gets empty string for $bundle parameter... And in some cases for me it is required to construct

Steps to reproduce

Proposed resolution

When I have time I will take a look, and try to fix this

Remaining tasks

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

DavorHorvacki created an issue. See original summary.

geek-merlin’s picture

Version: 8.x-1.0-rc1 » 8.x-1.x-dev
Priority: Normal » Critical

I get a WSOD as a result of this, trying to add a base field override for a commerce order item:

The website encountered an unexpected error. Please try again later.

RuntimeException: Could not load the "" order item type. in Drupal\commerce_order\Entity\OrderItem::bundleFieldDefinitions() (line 505 of modules/contrib/commerce/modules/order/src/Entity/OrderItem.php).

Drupal\Core\Entity\EntityFieldManager->buildBundleFieldDefinitions() (Line: 350)
Drupal\Core\Entity\EntityFieldManager->getFieldDefinitions() (Line: 124)
Drupal\base_field_override_ui\Controller\BaseFieldOverrideController->addAccess()
call_user_func_array() (Line: 75)
Drupal\Core\Access\CustomAccessCheck->access()
call_user_func_array() (Line: 159)
Drupal\Core\Access\AccessManager->performCheck() (Line: 135)
Drupal\Core\Access\AccessManager->check() (Line: 112)
Drupal\Core\Access\AccessManager->checkRequest() (Line: 109)
Drupal\Core\Routing\AccessAwareRouter->checkAccess() (Line: 94)
Drupal\Core\Routing\AccessAwareRouter->matchRequest() (Line: 112)
Symfony\Component\HttpKernel\EventListener\RouterListener->onKernelRequest()
call_user_func() (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (Line: 134)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 57)
Drupal\Core\StackMiddleware\Session->handle() (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 23)
Stack\StackedHttpKernel->handle() (Line: 717)
Drupal\Core\DrupalKernel->handle() (Line: 19)
require('/home/merlin/PhpstormProjects/c4c-dev/web/index.php') (Line: 46)
geek-merlin’s picture

Some quick debugging:
- Routes are altered in \Drupal\base_field_override_ui\Routing\RouteSubscriber::alterRoutes
- The throwing access callback is \Drupal\base_field_override_ui\Controller\BaseFieldOverrideController::addAccess

Strange enough, for e.g. Node title it "works"
- /admin/structure/types/manage/example_content_type/fields/base-field-override/title/add => works
- \Drupal\node\Entity\Node field_ui_base_route = "entity.node_type.edit_form"
- \Drupal\node\Entity\NodeType "edit-form" = "/admin/structure/types/manage/{node_type}"

...but for Order item unit pride, it breaks:
- /admin/commerce/config/order-item-types/c4c_share/edit/fields/base-field-override/unit_price/add => throws
- \Drupal\commerce_order\Entity\OrderItem field_ui_base_route = "entity.commerce_order_item_type.edit_form"
- \Drupal\commerce_order\Entity\OrderItemType "edit-form" = "/admin/commerce/config/order-item-types/{commerce_order_item_type}/edit"

The only difference i see is that for order item, the route has a component after the bundle, but i can't phantasize how that can make a difference.

I also did not test, if the node access check gets the correct bundle, or if it just does not throw.

mnico made their first commit to this issue’s fork.

mnico’s picture

Status: Active » Needs review

Hi, I just made a merge request that would fix the problem. ;)

Regards

geek-merlin’s picture

Status: Needs review » Reviewed & tested by the community

Chapeau, that was really quick!

I can confirm that the MR fixes the issue for me, it allows me to add and delete a base field override for order items.

Code looks straightforward, the solution is like i'd have guessed.
One nit: I'd suggest inlining the getParametersFromRouteMatch() method (factoring out seems more confusion than clarification to me). YMMV.

mnico’s picture

Status: Reviewed & tested by the community » Needs review

Thanks. Well I was reviewing the implementation and I realized that the RouteMatch service is required only to extract the bundle property in the addAccess method. In the other methods it is not necessary. So with this I remove the getParametersFromRouteMatch method.

Regards

holo96’s picture

Status: Needs review » Reviewed & tested by the community

Solved issue for me.

geek-merlin’s picture

I also can confirm worksforme.

  • mnico committed e311595 on 8.x-1.x
    Issue #3203857 by mnico: Bundle is always empty string in _custom_access...
mnico’s picture

Status: Reviewed & tested by the community » Fixed

Thanks!

geek-merlin’s picture

Thanks for mergin quickly!

Status: Fixed » Closed (fixed)

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