Feature/publication validation#139
Conversation
033a393 to
fe3869b
Compare
…file, also saved in the metadata DB
…epositories field in metadata form codecheckers#144
* Correct capitalization of 'CODECHECK metadata' * Add a missing " to close a msgstr * Rephrase some messages on validation
| } | ||
|
|
||
| public function validateCodecheckStatus(string $hookName, array $args): bool | ||
| public function validatePublication(string $hookName, array $args): bool |
There was a problem hiding this comment.
This validation function seems never to return true anymore.
There was a problem hiding this comment.
Ohhh now I see what you mean. No that is actually down to something completely different and intended.
It is down to how OJS handles hooks. The publication will be invalid, whenever we ship at least one error in the $errors Array. And it will be valid, whenever the array is empty.
The return value of this function doesn't have to do anything with the publication validation. Instead it has to do with how OJS handles this hook. If true where to be returned, the Hook: 'Publication::validatePublish' would stop to be called (meaning that for other plugins & OJS itsself this Hook wouldn't be fired anymore, if we have invalid metadata). This of course means, that e.g. if a submission is in the review stage, but somehow the editor already wants to publish it, we never get to see this error during the publication validation (because our invalid CODECHECK data would stop the hook).
To prevent this, it is best practise to always return false on a Hook, so other Plugins and OJS itsself get to call the Hook as well after our plugin did.
There was a problem hiding this comment.
Please document this in the function documentation then (a one line comment next to the "return false" also makes sense), and rename the function also, maybe end it in ...Hook ?
Then it is clear that the return value is not about the validation result but about the processing of the hook;
There was a problem hiding this comment.
How it looks now:
/**
* The publication will be invalid, whenever we ship at least one error in the `$errors` Array. And it will be valid, whenever the array is empty.
* The return value of this function doesn't have to do anything with the publication validation. Instead it has to do with how OJS handles this hook. If `true` where to be returned, the Hook: `'Publication::validatePublish'` would stop to be called (meaning that for other plugins & OJS itsself this Hook wouldn't be fired anymore, if we have invalid metadata). This of course means, that e.g. if a submission is in the review stage, but somehow the editor already wants to publish it, we never get to see this error during the publication validation (because our invalid CODECHECK data would stop the hook).
* To prevent this, it is best practise to always return `false` on a Hook, so other Plugins and OJS itsself get to call the Hook as well after our plugin did.
*
* @param string $hookName The name of the Hook (`'Publication::validatePublish'`)
* @param array $args The arguments of the Hook including the validation `$errors` Array at `&$args[0]`
*
* @return bool Returns `false` to enable OJS itsself and other Plugins to continue with their implementation for this Hook
*/
public function validatePublicationHook(string $hookName, array $args): bool
{
CodecheckLogger::debug("Validating Publication!");
$errors = &$args[0];
$codecheckPublicationValidator = new CodecheckPublicationValidator($this);
$validationErrors = $codecheckPublicationValidator->validatePublication();
if(is_array($validationErrors)) {
$errors = array_merge($errors, $validationErrors);
}
/* Returns `false` to enable OJS itsself and other Plugins to continue with their implementation for this Hook */
return false;
}…js-codecheck into feature/publication-validation
Closes #132, closes #141; ! IMPORTANT: Needs #139 to be merged first - - - CODECHECK Status Update: Based on the OJS workflow, create a list of "events" that are worth documenting in the register (article reviewed, editorial decisions (reject), certificate published, ...). This is related to #32 and what kind of information can be publicly revealed when. - [x] CODECHECK status should be recorded in the GitHub Issue - [x] CODECHECK status should be updated in the GitHub Issue - [x] status update / recording in the issue should be able to be turned off in the plugin settings - - - Fix CODECHECK status information, when CODECHECK was not yet started / is pending - [x] show that status is pending - [ ] ~act on pending behavior when it is checked if CODECHECK was already started in publication update~
Closes #12,
closes #122,
closes #143,
closes #144,
closes #145,
closes #146
!!! Firstly please look at the issue listed above, to see exactly which features this PR introduces.
This PR introduces the
CodecheckPublicationValidator.phpwhich validates things like the CODECHECK status, the producedcodecheck.ymlfile and more.I reworked the Settings Form UI a bit as well in this PR, to group together related settings (e.g. Settings concerning the GitHub Register, or settings concerning the Submission stage, or settings concerning the publication validation stage).