Skip to content

fix: remove content* methods from UrlPdfBuilder and UrlScreenshotBuilder#266

Closed
marilenaRM wants to merge 3 commits into
sensiolabs:1.xfrom
marilenaRM:fix/remove-content-methods-from-url-builders
Closed

fix: remove content* methods from UrlPdfBuilder and UrlScreenshotBuilder#266
marilenaRM wants to merge 3 commits into
sensiolabs:1.xfrom
marilenaRM:fix/remove-content-methods-from-url-builders

Conversation

@marilenaRM

@marilenaRM marilenaRM commented May 6, 2026

Copy link
Copy Markdown
Q A
Gotenberg API version ? 8.x
Bug fix ? yes
New feature ? no
BC break ? no
Issues Fix #257

Description

For URL-based builders, the page body is provided by the URL itself. Exposing content(), contentRaw() and contentFile() was misleading since those methods have no effect on URL conversions.

Superseded by #274

@Jean-Beru Jean-Beru left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks you @marilenaRM !

It could be considered as a BC break but it's a bug fix... Maybe deprecating these methods will be more appropriated. WDYT @Neirda24 @StevenRenaux

PS: don't forget to update UPGRADE file to mention this change.

@StevenRenaux

Copy link
Copy Markdown
Collaborator

Thanks you @marilenaRM !

It could be considered as a BC break but it's a bug fix... Maybe deprecating these methods will be more appropriated. WDYT @Neirda24 @StevenRenaux

PS: don't forget to update UPGRADE file to mention this change.

It would work I would say yes to the BC break but as it is not the case, not sure of the usefulness

@Neirda24

Neirda24 commented May 6, 2026

Copy link
Copy Markdown
Contributor

Shouldn't we split this in a dedicated trait ? As experienced before in this project we noticed that handling trait conflict while using reflection might just get things messy. Not in this specific case though.

Don't mind the BC it is a bugfix to me as it doesn't produce anything I guess.

@marilenaRM marilenaRM force-pushed the fix/remove-content-methods-from-url-builders branch from d0458fd to 31a781b Compare May 7, 2026 07:17
@marilenaRM

Copy link
Copy Markdown
Author

Hello ! :)

@Jean-Beru : I just added a commit for the update of the file UPGRADE :)
@Neirda24 and @StevenRenaux the BC break notification seems better since we remove some (most certainly not used) public functions, so in my opinion it should be noticed.

@Neirda24 I pushed a separate commit for a way to introduce a separated Trait, WDYT?

@Jean-Beru

Copy link
Copy Markdown
Contributor

Don't mind the BC it is a bugfix to me as it doesn't produce anything I guess.

That's the reason why it can break current code. The following code works even if the content method is ignored. Removing it will lead to fatal a error.

$builder
    ->content(/*...*/)
    ->url(/* ... */)

Shouldn't we split this in a dedicated trait ?

👍

ContentTrait can be split in 2 traits: content vs. header/footer (a.k.a. marginal ?).

Then we could:

  • deprecated content* methods in UrlPdfBuilder
  • deprecate header* and footer* methods in ContentTrait and invite to use MarginalTrait instead
  • use MarginalTrait in our builder to override the deprecated header* and footer* methods

Later we could:

  • remove ContentTrait usage in UrlPdfBuilder and MarkdownPdfBuilder
  • remove header* and footer* methods in ContentTrait

@StevenRenaux

Copy link
Copy Markdown
Collaborator

Don't mind the BC it is a bugfix to me as it doesn't produce anything I guess.

That's the reason why it can break current code. The following code works even if the content method is ignored. Removing it will lead to fatal a error.

$builder
    ->content(/*...*/)
    ->url(/* ... */)

Shouldn't we split this in a dedicated trait ?

👍

ContentTrait can be split in 2 traits: content vs. header/footer (a.k.a. marginal ?).

Then we could:

  • deprecated content* methods in UrlPdfBuilder
  • deprecate header* and footer* methods in ContentTrait and invite to use MarginalTrait instead
  • use MarginalTrait in our builder to override the deprecated header* and footer* methods

Later we could:

  • remove ContentTrait usage in UrlPdfBuilder and MarkdownPdfBuilder
  • remove header* and footer* methods in ContentTrait

This solution LGTM 🤩

@marilenaRM

Copy link
Copy Markdown
Author

so, what's the plan? deprecate in 1.2 and BC Break in 2.0?
maybe we should also address the usage of header and footer in ScreenShots in the referenced issue, deprecate them as well? I'll roll back my changes and split the Traits responsabilities, if that's ok with you

@Jean-Beru

Copy link
Copy Markdown
Contributor

so, what's the plan? deprecate in 1.2 and BC Break in 2.0? maybe we should also address the usage of header and footer in ScreenShots in the referenced issue, deprecate them as well? I'll roll back my changes and split the Traits responsabilities, if that's ok with you

LGTM

@Jean-Beru Jean-Beru added this to the v1.2 milestone May 12, 2026
Marilena Ruffelaere added 3 commits May 19, 2026 10:02
header*, footer* methods move to the new PageMarginalTrait. The original
methods remain in ContentTrait as deprecated no-ops (E_USER_DEPRECATED,
will be removed in 2.0) for BC, allowing existing code to receive a
deprecation warning rather than a runtime error.

ChromiumPdfTrait is updated to prefer PageMarginalTrait over the
deprecated ContentTrait stubs via insteadof. Screenshot builders keep
using ContentTrait directly since Gotenberg does not support headers and
footers for screenshots; the deprecated stubs are filtered out of the
generated documentation.

The deprecation message was corrected: the stubs in ContentTrait are
only ever called by builders that do not use PageMarginalTrait (e.g.
screenshot builders), so saying "Use PageMarginalTrait instead" would
be misleading. The message now states that header/footer support is
not available on the current builder.
Since the page body is fetched from the URL itself, content(),
contentRaw() and contentFile() are meaningless on URL-based builders.
They are now deprecated via DeprecatedBodyContentTrait (no-op +
E_USER_DEPRECATED) and will be removed in 2.0.
Three bugs fixed in docs/generate.php:

- @example merge: when a method appears in multiple traits (e.g. via
  insteadof resolution), the @example from the winning trait was silently
  discarded because the merge loop did not handle the example tag. The
  last seen @example now wins.

- Description merge: a docblock containing only tags (@deprecated, @see,
  etc.) produces an empty description array [], which is distinct from
  [''] and incorrectly satisfied the overwrite condition, erasing a
  previously collected verbose description. The condition now guards
  against both empty forms.

- Deprecated method filtering: public methods whose resolved docblock
  carries @deprecated are now excluded from the generated output. This
  prevents no-op stubs from appearing in the documentation without any
  useful content.
@marilenaRM marilenaRM force-pushed the fix/remove-content-methods-from-url-builders branch from 3f81f67 to b84f329 Compare May 19, 2026 08:17
@Neirda24 Neirda24 modified the milestones: v1.2, v1.3 May 19, 2026
@marilenaRM marilenaRM closed this May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Remove content* methods from UrlBuilder

4 participants