Problem/Motivation

Installing this module when jsonapi is installed results in a TypeError

TypeError: Argument 1 passed to Drupal\jsonapi\Access\EntityAccessChecker::setMediaRevisionAccessCheck() must be an instance of Drupal\media\Access\MediaRevisionAccessCheck, instance of Drupal\media_revisions_ui\Access\MediaRevisionAccessCheck given in /data/app/core/modules/jsonapi/src/Access/EntityAccessChecker.php on line 135 #0 [internal function]: Drupal\jsonapi\Access\EntityAccessChecker->setMediaRevisionAccessCheck(Object(Drupal\media_revisions_ui\Access\MediaRevisionAccessCheck))

Proposed resolution

Drupal\media_revisions_ui\Access\MediaRevisionAccessCheck should extend Drupal\media\Access\MediaRevisionAccessCheck

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#5 3117019-5.patch4.82 KBbcizej
#5 interdiff_2-5.txt1.4 KBbcizej
#2 3117019-2.patch4.58 KBbcizej

Comments

acbramley created an issue. See original summary.

bcizej’s picture

StatusFileSize
new4.58 KB

Hi, thanks for reporting this. I had initially thought to extend from core media access checker class but didn't at the end.

Here is a patch that fixes this.

bcizej’s picture

Status: Active » Needs review
acbramley’s picture

+++ b/src/Access/MediaRevisionAccessCheck.php
@@ -38,44 +24,22 @@ class MediaRevisionAccessCheck implements AccessInterface {
-  public function access(Route $route, AccountInterface $account, $media_revision = NULL, MediaInterface $media = NULL) {
+  public function access(
+    Route $route,
+    AccountInterface $account,
+    $media_revision = NULL,
+    MediaInterface $media = NULL
+  ) {

I would probably just keep this on one line, but that's a personal preference :)

You could also just simply call parent::access() and then add your cache tags on top.

bcizej’s picture

StatusFileSize
new1.4 KB
new4.82 KB

1. Yeah I guess I'll also open a new ticket to bring the constructors everywhere to one-liners.
2. :facepalm: Of course, thanks!

acbramley’s picture

Status: Needs review » Reviewed & tested by the community

@benjamincizej nice one!

  • benjamincizej committed ab8fc04 on 8.x-1.x
    Issue #3117019 by benjamincizej, acbramley: Incompatible with JSONAPI
    
bcizej’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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