Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal error accessing workflow as copyeditor #7822

Closed
NateWr opened this issue Apr 4, 2022 · 11 comments
Closed

Fatal error accessing workflow as copyeditor #7822

NateWr opened this issue Apr 4, 2022 · 11 comments
Labels
Bug:1:Low A bug that does not have a severe consequence or affects a small number of users. Try Me This issue might be good for a new contributor. Can you help us?
Milestone

Comments

@NateWr
Copy link
Contributor

NateWr commented Apr 4, 2022

Describe the bug
When assigned as a copyeditor, I can not access the submission workflow because of a fatal error. This only effects PHP 8.0 or above because array_intersect is more strict about the arguments it accepts.

To Reproduce
Steps to reproduce the behavior:

  1. Run a site in PHP 8.0 or above.
  2. Assign a copyeditor to a submission.
  3. Login as the copyeditor.
  4. Try to view the submission workflow.
  5. See error

What application are you using?
Effects main and stable-3_3_0. This fix should be backported to 3.3.0, because eventually it will need to support PHP 8.0.

Additional information
The error:

PHP Fatal error:  Uncaught TypeError: array_intersect(): Argument #2 must be of type array, null given in lib/pkp/pages/workflow/PKPWorkflowHandler.inc.php:167
Stack trace:
#0 lib/pkp/pages/workflow/PKPWorkflowHandler.inc.php(167): array_intersect(Array, NULL)
#1 [internal function]: PKPWorkflowHandler->index(Array, Object(APP\core\Request))
#2 lib/pkp/classes/core/PKPRouter.inc.php(465): call_user_func(Array, Array, Object(APP\core\Request))
#3 lib/pkp/classes/core/PKPPageRouter.inc.php(308): PKP\core\PKPRouter->_authorizeInitializeAndCallRequest(Array, Object(APP\core\Request), Array, false)
#4 lib/pkp/classes/core/Dispatcher.inc.php(163): PKP\core\PKPPageRouter->route(Object(APP\core\Request))
#5 lib/pkp/classes/core/PKPApplication.inc.php(376): PKP\core\Dispatcher->dispatch(Object(APP\core\Request))
#6 index.php(70): PKP\core\PKPApplication->execute()
#7 {main}
  thrown in lib/pkp/pages/workflow/PKPWorkflowHandler.inc.php on line 167
@NateWr NateWr added the Bug:1:Low A bug that does not have a severe consequence or affects a small number of users. label Apr 4, 2022
@NateWr NateWr added this to the 3.3.0-11 milestone Apr 4, 2022
@NateWr NateWr added the Try Me This issue might be good for a new contributor. Can you help us? label Apr 4, 2022
@asmecher
Copy link
Member

asmecher commented Apr 4, 2022

@NateWr, FYI, I think this is a PHP8.1 and up issue. I've been tracking/fixing these in #7690.

@NateWr
Copy link
Contributor Author

NateWr commented Apr 4, 2022

I've run into it on PHP 8.0.17.

@asmecher
Copy link
Member

asmecher commented Apr 4, 2022

Hrm, interesting -- I'm using 8.0.2 without trouble and Travis is using 8.0.9. More data required 🤷

@NateWr
Copy link
Contributor Author

NateWr commented Apr 4, 2022

Have you tried the reproduction steps? I think this only occurs when an ASSISTANT user without access to the production stage is assigned, and tries to access the workflow. I'm not sure if that's part of our tests.

@asmecher
Copy link
Member

asmecher commented Apr 4, 2022

Yes, but I didn't see the problem on my machine (in fact, not using PHP8.1.2 either). Are you using one of the test dataset accounts? I'm using mfritz.

@NateWr
Copy link
Contributor Author

NateWr commented Apr 5, 2022

I was able to reproduce this using the test dataset on stable-3_3_0 on PHP 8.0.17. Here are some more precise reproduction steps:

  1. Download the test database for stable-3_3_0 from here: https://github.com/pkp/datasets/tree/main/ojs/stable-3_3_0/pgsql
  2. Create new database, ojs_i7822, and import the SQL.
  3. Configure an install of stable-3_3_0 to use that database.
  4. Login as admin.
  5. Go to http://localhost:8000/publicknowledge/workflow/index/19/4.
  6. Login as the copyeditor, Sarah Vogt (svogt).
  7. See a white-screen and find the the following error messages.
[05-Apr-2022 10:29:20 Europe/London] PHP Warning:  Undefined array key 5 in ojs-330/lib/pkp/pages/workflow/PKPWorkflowHandler.inc.php on line 157
[05-Apr-2022 10:29:20 Europe/London] PHP Fatal error:  Uncaught TypeError: array_intersect(): Argument #2 must be of type array, null given in ojs-330/lib/pkp/pages/workflow/PKPWorkflowHandler.inc.php:157
Stack trace:
#0 ojs-330/lib/pkp/pages/workflow/PKPWorkflowHandler.inc.php(157): array_intersect(Array, NULL)
#1 ojs-330/lib/pkp/classes/core/PKPRouter.inc.php(395): PKPWorkflowHandler->index(Array, Object(Request))
#2 ojs-330/lib/pkp/classes/core/PKPPageRouter.inc.php(246): PKPRouter->_authorizeInitializeAndCallRequest(Array, Object(Request), Array, false)
#3 ojs-330/lib/pkp/classes/core/Dispatcher.inc.php(144): PKPPageRouter->route(Object(Request))
#4 ojs-330/lib/pkp/classes/core/PKPApplication.inc.php(362): Dispatcher->dispatch(Object(Request))
#5 ojs-330/index.php(68): PKPApplication->execute()
#6 {main}
  thrown in ojs-330/lib/pkp/pages/workflow/PKPWorkflowHandler.inc.php on line 157

I tested using PHP's built-in server with the following command:

php -S localhost:8000 -c ../_server/php.ini

I'm using PHP 8.0.17.

$ php -v                                     
PHP 8.0.17 (cli) (built: Mar 20 2022 17:04:09) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.17, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.17, Copyright (c), by Zend Technologies

And just in case it matters, this is what my custom php.ini file looks like (to channel all errors to the same place):

display_errors = Off
error_log = /home/nate/Projects/pkp/_server/error.log
log_errors = On
# error_reporting = E_ALL
error_reporting = E_ALL ^ E_STRICT
date.timezone = Europe/London
upload_max_filesize = 20M
post_max_size = 20M
max_execution_time = 10

@mariuszsienkiewicz
Copy link
Contributor

So is it only a need to change this:

$canAccessProduction = (bool) array_intersect($editorialWorkflowRoles, $accessibleWorkflowStages[WORKFLOW_STAGE_ID_PRODUCTION]);

into this:

$canAccessProduction = (bool) array_intersect($editorialWorkflowRoles, $accessibleWorkflowStages[WORKFLOW_STAGE_ID_PRODUCTION]  ?? []);

in a couple of places?

@NateWr
Copy link
Contributor Author

NateWr commented Apr 13, 2022

Yes, I think so.

@asmecher
Copy link
Member

Thanks, @NateWr and @mariuszsienkiewicz -- I've transformed your suggestion into a couple of pull requests, Mariusz:

The appropriate PR/patch should be applied in the lib/pkp subdirectory.

If either of you can confirm that this resolves the issue, I can commit it!

@NateWr
Copy link
Contributor Author

NateWr commented Apr 18, 2022

I can confirm this resolved the issue in stable-3_3_0.

@asmecher
Copy link
Member

This was actually fixed in 3.3.0-11 -- reopening that milestone temporarily to correct the record, and closing this issue. Thanks all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug:1:Low A bug that does not have a severe consequence or affects a small number of users. Try Me This issue might be good for a new contributor. Can you help us?
Projects
None yet
Development

No branches or pull requests

3 participants