Skip to content

pkp/pkp-lib#10431 Hooks in policy to relax author file upload#12390

Open
touhidurabir wants to merge 3 commits intopkp:mainfrom
touhidurabir:i10431_main
Open

pkp/pkp-lib#10431 Hooks in policy to relax author file upload#12390
touhidurabir wants to merge 3 commits intopkp:mainfrom
touhidurabir:i10431_main

Conversation

@touhidurabir
Copy link
Copy Markdown
Member

for #10431 .

Copy link
Copy Markdown
Member

@asmecher asmecher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few minor changes here.

}

// Give plugin a chance to override the submission file stage access policy
Hook::run('SubmissionFileStageAccessPolicy::effect', [$submission, $userRoles, $stageAssignments, $this->_fileStage, $this->_action, &$assignedFileStages]);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer named parameters for new hooks:

Suggested change
Hook::run('SubmissionFileStageAccessPolicy::effect', [$submission, $userRoles, $stageAssignments, $this->_fileStage, $this->_action, &$assignedFileStages]);
Hook::run('SubmissionFileStageAccessPolicy::effect', ['submission' => $submission, 'userRoles' => $userRoles, 'stageAssignments' => $stageAssignments, 'fileStage' => $this->_fileStage, 'action' => $this->_action, 'assignedFileStages' => &$assignedFileStages]);

This makes for a lot less ambiguity in the hook callback functions, which would otherwise depend on function orders to know what parameters are being passed.

/**
* @see AuthorizationPolicy::effect()
*
* @hook SubmissionFileStageAccessPolicy::effect [[$submission, $userRoles, $stageAssignments, $this->_fileStage, $this->_action, &$assignedFileStages]]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is incorrect, now that you're using Hook::run instead of Hook::call.

Suggested change
* @hook SubmissionFileStageAccessPolicy::effect [[$submission, $userRoles, $stageAssignments, $this->_fileStage, $this->_action, &$assignedFileStages]]
* @hook SubmissionFileStageAccessPolicy::effect [$submission, $userRoles, $stageAssignments, $this->_fileStage, $this->_action, &$assignedFileStages]

* @param int $submissionFileId
* @param string $submissionParameterName
*
* @hook SubmissionFileAccessPolicy::authorFileAccess [[$request, $mode, $submissionFileId, &$authorFileAccessOptionsPolicy]]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above

Suggested change
* @hook SubmissionFileAccessPolicy::authorFileAccess [[$request, $mode, $submissionFileId, &$authorFileAccessOptionsPolicy]]
* @hook SubmissionFileAccessPolicy::authorFileAccess [$request, $mode, $submissionFileId, &$authorFileAccessOptionsPolicy]

}

// Give plugin a chance to modify/add policies for author to access
Hook::run('SubmissionFileAccessPolicy::authorFileAccess', [$request, $mode, $submissionFileId, &$authorFileAccessOptionsPolicy]);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above

Suggested change
Hook::run('SubmissionFileAccessPolicy::authorFileAccess', [$request, $mode, $submissionFileId, &$authorFileAccessOptionsPolicy]);
Hook::run('SubmissionFileAccessPolicy::authorFileAccess', ['request' => $request, 'mode' => $mode, 'submissionFileId' => $submissionFileId, 'authorFileAccessOptionsPolicy' => &$authorFileAccessOptionsPolicy]);

@touhidurabir touhidurabir force-pushed the i10431_main branch 2 times, most recently from 5268247 to de00235 Compare March 29, 2026 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants