Skip to content

Feature/publication validation#139

Merged
nuest merged 17 commits into
codecheckers:mainfrom
dxL1nus:feature/publication-validation
Jul 13, 2026
Merged

Feature/publication validation#139
nuest merged 17 commits into
codecheckers:mainfrom
dxL1nus:feature/publication-validation

Conversation

@dxL1nus

@dxL1nus dxL1nus commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

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.php which validates things like the CODECHECK status, the produced codecheck.yml file 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).

grafik

@dxL1nus dxL1nus self-assigned this Jun 29, 2026
@dxL1nus dxL1nus mentioned this pull request Jul 6, 2026
5 tasks
@dxL1nus
dxL1nus force-pushed the feature/publication-validation branch from 033a393 to fe3869b Compare July 10, 2026 18:25
@dxL1nus
dxL1nus requested a review from nuest July 11, 2026 15:39
@dxL1nus
dxL1nus marked this pull request as ready for review July 11, 2026 17:25
* Correct capitalization of 'CODECHECK metadata'
* Add a missing " to close a msgstr
* Rephrase some messages on validation

@nuest nuest left a comment

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 have just one critical point about a validation function, maybe it must be renamed.

Minor things re. this PR added to a follow-up issue for later, to not hold this merging up: #148

Comment thread CodecheckPlugin.php Outdated
}

public function validateCodecheckStatus(string $hookName, array $args): bool
public function validatePublication(string $hookName, array $args): bool

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.

This validation function seems never to return true anymore.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

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.

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;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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;
}

@nuest nuest mentioned this pull request Jul 13, 2026
@nuest
nuest self-requested a review July 13, 2026 10:06
@nuest
nuest merged commit 1ad53fa into codecheckers:main Jul 13, 2026
2 of 3 checks passed
nuest added a commit that referenced this pull request Jul 13, 2026
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~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment