Problem/Motivation

On installing the extension I got the following error:

Error: Call to undefined function Drupal\jsonapi_role_access\EventSubscriber\str_starts_with() in Drupal\jsonapi_role_access\EventSubscriber\CheckUserRolePermissionEvent->checkUserRoleAccess() (line 73 of modules/contrib/jsonapi_role_access/src/EventSubscriber/CheckUserRolePermissionEvent.php).

Steps to reproduce

Install the extension on a system running a version of php less than 8.0

Proposed resolution

A polyfill which first tries to call the "str_starts_with" else falls back to the polyfill.

CommentFileSizeAuthor
#2 jsonapi_role_access-3168679-2.patch1.16 KB3li

Comments

Eli.Stone created an issue. See original summary.

3li’s picture

StatusFileSize
new1.16 KB

arshadkhan35’s picture

Status: Active » Fixed

Thanks @Eli.Stone for the patch it looks good except for some variables description and data type missing in function comment doc, just to add the str_starts_with function is available from PHP 7.4 onward as I have tested on PHP7.4 and its working perfectly fine, it will throw exception for lower version hence accepting your proposed solution.

arshadkhan35’s picture

Version: 1.0.0-beta2 » 1.0.0-beta5
Status: Fixed » Closed (fixed)