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

pkp/pkp-lib#7822 Fix fatal error with pickier PHP release and array_intersect #7861

Merged
merged 1 commit into from
May 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function effect()
// Managers are allowed to access discussions they are not participants in
// as long as they have Manager-level access to the workflow stage
$accessibleWorkflowStages = $this->getAuthorizedContextObject(ASSOC_TYPE_ACCESSIBLE_WORKFLOW_STAGES);
$managerAssignments = array_intersect([Role::ROLE_ID_MANAGER], $accessibleWorkflowStages[$query->getStageId()]);
$managerAssignments = array_intersect([Role::ROLE_ID_MANAGER], $accessibleWorkflowStages[$query->getStageId()] ?? []);
if (!empty($managerAssignments)) {
return AuthorizationPolicy::AUTHORIZATION_PERMIT;
}
Expand Down
16 changes: 8 additions & 8 deletions pages/workflow/PKPWorkflowHandler.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function access($args, $request)
// Get the closest workflow stage that user has an assignment.
$workingStageId = null;
for ($workingStageId = $currentStageId; $workingStageId >= WORKFLOW_STAGE_ID_SUBMISSION; $workingStageId--) {
if (isset($accessibleWorkflowStages[$workingStageId]) && array_intersect($editorialWorkflowRoles, $accessibleWorkflowStages[$workingStageId])) {
if (isset($accessibleWorkflowStages[$workingStageId]) && array_intersect($editorialWorkflowRoles, $accessibleWorkflowStages[$workingStageId] ?? [])) {
break;
}
}
Expand All @@ -93,7 +93,7 @@ public function access($args, $request)
// submission. Try to get the closest future workflow stage.
if ($workingStageId == null) {
for ($workingStageId = $currentStageId; $workingStageId <= WORKFLOW_STAGE_ID_PRODUCTION; $workingStageId++) {
if (isset($accessibleWorkflowStages[$workingStageId]) && array_intersect($editorialWorkflowRoles, $accessibleWorkflowStages[$workingStageId])) {
if (isset($accessibleWorkflowStages[$workingStageId]) && array_intersect($editorialWorkflowRoles, $accessibleWorkflowStages[$workingStageId] ?? [])) {
break;
}
}
Expand Down Expand Up @@ -156,13 +156,13 @@ public function index($args, $request)
$canPublish = false; // Ability to publish, unpublish and create versions
$canAccessEditorialHistory = false; // Access to activity log
// unassigned managers
if (!$accessibleWorkflowStages && array_intersect($this->getAuthorizedContextObject(ASSOC_TYPE_USER_ROLES), [Role::ROLE_ID_MANAGER])) {
if (!$accessibleWorkflowStages && array_intersect($this->getAuthorizedContextObject(ASSOC_TYPE_USER_ROLES), [Role::ROLE_ID_MANAGER] ?? [])) {
$canAccessProduction = true;
$canPublish = true;
$canAccessPublication = true;
$canAccessEditorialHistory = true;
} elseif (!empty($accessibleWorkflowStages[$currentStageId]) && array_intersect($editorialWorkflowRoles, $accessibleWorkflowStages[$currentStageId])) {
$canAccessProduction = (bool) array_intersect($editorialWorkflowRoles, $accessibleWorkflowStages[WORKFLOW_STAGE_ID_PRODUCTION]);
} elseif (!empty($accessibleWorkflowStages[$currentStageId]) && array_intersect($editorialWorkflowRoles, $accessibleWorkflowStages[$currentStageId] ?? [])) {
$canAccessProduction = (bool) array_intersect($editorialWorkflowRoles, $accessibleWorkflowStages[WORKFLOW_STAGE_ID_PRODUCTION] ?? []);
$canAccessPublication = true;

$stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO'); /** @var StageAssignmentDAO $stageAssignmentDao */
Expand All @@ -176,7 +176,7 @@ public function index($args, $request)
// for the production workflow stage. An unassigned admin or manager may
// have been granted access and should be allowed to publish.
if (empty($result) && is_array($accessibleWorkflowStages[WORKFLOW_STAGE_ID_PRODUCTION])) {
$canPublish = (bool) array_intersect([Role::ROLE_ID_SITE_ADMIN, Role::ROLE_ID_MANAGER], $accessibleWorkflowStages[WORKFLOW_STAGE_ID_PRODUCTION]);
$canPublish = (bool) array_intersect([Role::ROLE_ID_SITE_ADMIN, Role::ROLE_ID_MANAGER], $accessibleWorkflowStages[WORKFLOW_STAGE_ID_PRODUCTION] ?? []);

// Otherwise, check stage assignments
// "Recommend only" stage assignments can not publish
Expand All @@ -192,7 +192,7 @@ public function index($args, $request)
}
}
}
if (!empty($accessibleWorkflowStages[$currentStageId]) && array_intersect([Role::ROLE_ID_MANAGER, Role::ROLE_ID_SUB_EDITOR], $accessibleWorkflowStages[$currentStageId])) {
if (!empty($accessibleWorkflowStages[$currentStageId]) && array_intersect([Role::ROLE_ID_MANAGER, Role::ROLE_ID_SUB_EDITOR], $accessibleWorkflowStages[$currentStageId] ?? [])) {
$canAccessEditorialHistory = true;
}
/** @var GenreDAO $genreDao */
Expand Down Expand Up @@ -406,7 +406,7 @@ public function index($args, $request)
}

// Add the revision decision/recommendation forms if this app supports a review stage
if (count(array_intersect([WORKFLOW_STAGE_ID_INTERNAL_REVIEW, WORKFLOW_STAGE_ID_EXTERNAL_REVIEW], Application::getApplicationStages()))) {
if (count(array_intersect([WORKFLOW_STAGE_ID_INTERNAL_REVIEW, WORKFLOW_STAGE_ID_EXTERNAL_REVIEW], Application::getApplicationStages() ?? []))) {
$selectRevisionDecisionForm = new PKP\components\forms\decision\SelectRevisionDecisionForm();
$selectRevisionRecommendationForm = new PKP\components\forms\decision\SelectRevisionRecommendationForm();
$state['components'][$selectRevisionDecisionForm->id] = $selectRevisionDecisionForm->getConfig();
Expand Down