Problem/Motivation

We have a site that only protects a handful of individual pages using this module, none of them are jsonapi paths. Upon upgrading from 8.x-1.8 to 8.x-1.9, paginated jsonapi requests now fail with the following error:
Input value "page" contains a non-scalar value.

Steps to reproduce

Navigate to this path on your site while not logged in:
https://example.ddev.site/jsonapi/node/article?page%5Boffset%5D=50&page%5Blimit%5D=50
On protected_pages 8x.-1.8, this returns a json list of articles.
On protected_pages 8.x-1.9, this fails with the following output:

{
  "jsonapi": {
    "version": "1.0",
    "meta": {
      "links": {
        "self": {
          "href": "http://jsonapi.org/format/1.0/"
        }
      }
    }
  },
  "errors": [
    {
      "title": "Bad Request",
      "status": "400",
      "detail": "Input value \"page\" contains a non-scalar value.",
      "links": {
        "via": {
          "href": "https://example.ddev.site/jsonapi/node/article?page%5Boffset%5D=50&page%5Blimit%5D=50"
        },
        "info": {
          "href": "https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1"
        }
      }
    }
  ]
}

Proposed resolution

Fix the bug so that jsonapi URLs no longer fail when the module is enabled.

CommentFileSizeAuthor
#4 jsonapi_protected_pages.patch737 bytesrowanadev
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

fernando iglesias created an issue. See original summary.

fernando iglesias’s picture

Issue summary: View changes
adstokoe’s picture

I'm seeing the same issue. I agree it's a major issue. Any updates on a fix for this?

rowanadev’s picture

StatusFileSize
new737 bytes

Good morning, I've created a patch which will fix this for JSONAPI urls temporarily while we figure out a permenant solution. The issue is being caused by the loadAllProtectedPages() function which extends the PageSelectExtender class which will call the getPagerParameters() function within the pagerParamters class, this is where the code will error out as it converts the pager parameters.

The patch I've created will skip this step if it is a JSONAPI url.

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

froboy’s picture

Status: Active » Reviewed & tested by the community

@rowanadev this patch worked well for us, thank you!

Drupal.org guidance now says "Patch files are no longer recommended, use merge requests instead."

I've moved your patch to a MR so it's easier for the maintainers to review and merge.

fernando iglesias’s picture

Hello, just wanted to update you that MR43 resolves the issue on our end - thanks!

rowanadev’s picture

My apologies, thank you for doing this @froboy.

steven jones’s picture

I reckon that the fix in #3557159: Wildcard path conditions don't apply after 20 entries might also sort things out here.

marco.pagliarulo’s picture

If you are willing to give it a try, I implemented https://www.drupal.org/project/protected_pages_extra which is not affected by the issue since the redirect is performed at HTTP Middleware level instead of EventSubscriber.