Fix duplicate HTML content in HtmlMonographFilePlugin#2310
Open
zielaq wants to merge 1 commit intopkp:stable-3_5_0from
Open
Fix duplicate HTML content in HtmlMonographFilePlugin#2310zielaq wants to merge 1 commit intopkp:stable-3_5_0from
zielaq wants to merge 1 commit intopkp:stable-3_5_0from
Conversation
When an HTML publication format file is not assigned to a chapter,
$submissionFile->getData('chapterId') returns null. Passing null to
ChapterDAO::getChapter(int $chapterId) causes a TypeError in PHP 8.
The Hook::run() exception handler silently catches plugin exceptions
and continues, so downloadCallback fails to return Hook::ABORT.
CatalogBookHandler::download() then falls through to
app()->get('file')->download(), sending the file content a second time.
This fix guards the getChapter() call with a null check, consistent
with the existing pattern in CatalogBookHandler::download() (line 420).
36417e3 to
843a190
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
HtmlMonographFilePlugin::downloadCallback()when viewing HTML publication format files not assigned to a chapter$submissionFile->getData('chapterId')returnsnullfor non-chapter files, causingChapterDAO::getChapter(int)to throw a TypeError in PHP 8Hook::run()silently catches the plugin exception and continues, so the hook returnsCONTINUEinstead ofABORT—CatalogBookHandler::download()then sends the file a second time viaapp()->get('file')->download(), resulting in duplicate HTML contentFix
Guard the
getChapter()call with a null check (same pattern already used inCatalogBookHandler::download()at line 420):Test plan
/catalog/view/{id}/{formatId}/{fileId}