Skip to content

pkp/pkp-lib#12232 Fix null issueId and null suffix pattern TypeErrors in mintPublicationDoi#5529

Open
MrRob100 wants to merge 1 commit into
pkp:stable-3_4_0from
MrRob100:doi-automatic-registration-fix
Open

pkp/pkp-lib#12232 Fix null issueId and null suffix pattern TypeErrors in mintPublicationDoi#5529
MrRob100 wants to merge 1 commit into
pkp:stable-3_4_0from
MrRob100:doi-automatic-registration-fix

Conversation

@MrRob100
Copy link
Copy Markdown
Contributor

@MrRob100 MrRob100 commented May 1, 2026

Summary

Fixes two TypeError regressions in classes/doi/Repository.php introduced by #5170 (shipped in 3.4.0-10), which addressed pkp/pkp-lib#12005.

Both errors surface as HTTP 500 responses and affect journals using Custom Pattern DOI suffix type with Automatic DOI Assignment set to Upon reaching the copyediting stage.

Bug 1 — null issueId causes TypeError in mintPublicationDoi (pkp/pkp-lib#12232)

When a submission reaches copyediting without being assigned to an issue, $publication->getData('issueId') returns null. After #5170 restructured the issue guard, Repo::issue()->get() is now called unconditionally, but its signature requires int $id — passing null throws:

TypeError: APP\issue\Repository::get(): Argument #1 ($id) must be of type int, null given
  at classes/doi/Repository.php line 70

Fix: Extract $issueId first and only call Repo::issue()->get() when non-null.

Bug 2 — null suffix pattern causes TypeError in suffixHasIssuePattern()

When the Custom Pattern DOI format is selected but the Submissions pattern field is left blank, getPubIdSuffixPattern() returns null. PubIdPlugin::suffixHasIssuePattern() declares string $pubIdSuffix, so passing null throws:

TypeError: APP\plugins\PubIdPlugin::suffixHasIssuePattern(): Argument #1 ($pubIdSuffix) must be of type string, null given
  at classes/doi/Repository.php line 66

Fix: Extract the suffix pattern before calling suffixHasIssuePattern() and throw a DoiException when empty, so the editorial workflow continues cleanly rather than producing an unhandled 500.

Related

Test plan

  • Set DOI Format to Custom Pattern, leave the Submissions field blank → Bulk assign DOI for an unscheduled submission → confirm graceful DoiException instead of 500
  • Set DOI Format to Custom Pattern, Submissions pattern = %j-%a (no issue tokens), submission at copyediting with no issue assigned → confirm DOI mints without error
  • Set DOI Format to Custom Pattern, Submissions pattern includes %v/%i/%Y, submission with no issue → confirm existing PUBLICATION_MISSING_ISSUE DoiException still raised
  • Set DOI Format to Custom Pattern, submission assigned to an issue → confirm DOI mints correctly

🤖 Generated with Claude Code

… in mintPublicationDoi

Two regressions introduced by pkp#5170 (shipped in 3.4.0-10):

1. Repo::issue()->get() was called unconditionally with the publication's
   issueId, which is null for unscheduled submissions at copyediting stage.
   Guard issueId before calling get() to avoid the TypeError.

2. PubIdPlugin::suffixHasIssuePattern() declares string $pubIdSuffix but
   getPubIdSuffixPattern() returns null when the custom Submissions pattern
   field has never been saved. Extract the pattern first, and throw a
   DoiException (rather than an uncaught TypeError) when it is empty so
   the editorial workflow continues uninterrupted.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

1 participant