Wrong parameter order in checkPatchFieldAccess

Created on 25 October 2022, over 2 years ago
Updated 23 February 2023, about 2 years ago

Problem/Motivation

In CartUpdateItemResource.php the $original_field_item is the second parameter to "checkPatchFieldAccess":

      if ($this->inner->checkPatchFieldAccess($parsed_field_item, $original_field_item)) {

Whereas it's the first parameter in EntityResourceShim.php:

  /**
   * {@inheritdoc}
   */
  public function checkPatchFieldAccess(FieldItemListInterface $original_field, FieldItemListInterface $received_field) {
    return parent::checkPatchFieldAccess($original_field, $received_field);
  }

The issue that arises through this is that I only receive the $parsed_field_item in a field_access_hook which does not contain the actual parent entity which I would need for my access check. If I reverse the order of the parameters everything works as expected.

Proposed resolution

Change the code in CartUpdateItemResource.php to

      if ($this->inner->checkPatchFieldAccess($original_field_item, $parsed_field_item)) {

Remaining tasks

I will create a MR for this.

🐛 Bug report
Status

Fixed

Component

Code

Created by

🇦🇹Austria Cryt1c

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024