Repository navigation
Draw a repeated table header or footer with a background image without warnings (#742) - #750
Open
gravitypdf-bot wants to merge 2 commits into
Conversation
…t warnings (#742) TableHeaderFooter() read the gradient of each background layer of a repeated header or footer cell and row without checking it was there. A layer read from a URL has no gradient key, so every page the header or footer was drawn again raised "Undefined array key" warnings, which a strict error handler turns into a failed document. The first-page code in _tableWrite() already checks with isset(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…742) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Fixes #742
Found while working on #552
Stacked on #723
Problem
A table header or footer that is drawn again on later pages raises
Undefined array key "gradient"warnings on each of those pages when one of its cells or rows has abackground-imageloaded from a URL. The image itself is still drawn. The warnings are the only fault, but a strict error handler turns them into a failed document.Undefined array key "gradient"per cell or rowCause
TableHeaderFooter()reads$bg['gradient']for every background layer of a header or footer cell and row without checking that the key exists. A layer from a URL hasimage_idand nogradientkey._tableWrite()draws the same cell on the table's first page, and it checks the key withisset()first.This branch is stacked on #723 because #723 rewrites both of these lines into a loop over background layers. The unguarded read is still there after that rewrite, now as
$bg['gradient'].Fix
Both reads are now
!empty($bg['gradient']), the same check thatisset() && truthymakes elsewhere in the file.Legacy mode
This is a fix for a warning, and it applies in both
cssModes. Nothing on the page changes in either mode.Tests
tests/Mpdf/RepeatedTableHeaderBackgroundTest.phprenders a three-page table whose header cell, header row, footer cell or footer row has a background image, in both CSS modes (8 cases). It uses thePageStreamstrait'sassertDrawsSilently()to assert that nothing is raised, and it asserts that a pattern is painted on every page. All 8 cases fail against thesrc/on Draw every layer of a multiple background (#609) #723 with the warnings from lines 13361 and 13546, and they pass with the fix.Checks
composer test: OK (12770 tests, 31 skipped, none of them snapshots; the snapshot group alone passes 219/219, none skipped)composer cs: cleangravitypdf, none new🤖 Generated with Claude Code