Latest updates break sites on PHP 7.4

Created on 16 November 2023, about 1 year ago

Problem/Motivation

The \Drupal\views_conditional\Plugin\views\field\ViewsConditionalField::markup declares the return type MarkupInterface|string which is not allowed in PHP 7.4

Yes, PHP 7.4 is old, but some sites haven't made it to PHP 8 yet, and the module doesn't declare the PHP 8 dependency. So it should not be expecting it.

Also, that method never returns a string anyways, so the mixed type is not even correct at this point.

πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @jurgenhaas
  • Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 5.7
    last update about 1 year ago
    Waiting for branch to pass
  • Status changed to Needs review about 1 year ago
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    Provided an MR to fix this, please review.

  • πŸ‡ΊπŸ‡ΈUnited States shelane

    It does. See [Β£3400004]. This is why it was changed.

    What version of Drupal are you using?

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    This is happening on one of the last 9.5.11 Drupal sites that the customer has not approved the budget for the update yet.

  • Status changed to Closed: won't fix about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States shelane

    Drupal 9 minimum php requirements β†’ are php 8. In your case, I would use the patch, but maintainers try to stick with the Drupal requirements.

  • Status changed to Active 12 months ago
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    @shelane while I see and accept your point about Drupal 9, the declaration of the function's return type is still incorrect. It always returns MarkupInterface and never a string. I think this should still be fixed, even if it's for a different reason.

  • πŸ‡ΊπŸ‡ΈUnited States shelane

    Except that it does. I had it as MarkupInterface and then an error was reported in the issue I linked in #4. For php 8, we can accept either.

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    That's interesting, because the declaration of \Drupal\Core\Render\RendererInterface::render says, that it certainly only returns MarkupInterface.

    I've checked for implementations of that method, and that's just one: \Drupal\Core\Render\Renderer::render. That one returns the result from \Drupal\Core\Render\Renderer::doRender and that in fact returns empty strings under some circumstances.

    This looks like a core bug in my view.

  • Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 5.7
    last update 12 months ago
    Waiting for branch to pass
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    I have updated the MR such that it does not declare the return type any longer. That's the only way to keep it working on PHP 7.4 and also make sure that the string return type doesn't cause issue on PHP 8.1 - not sure how we get core to fix the issue at the source, so that all the declarations should be reliable.

  • πŸ‡¦πŸ‡·Argentina abelpzl

    I think a notice should be put on the module page to warn users that this module is not compatible with php 7.4.
    This would help avoid problems on sites that cannot yet upgrade to php 8.x / Durpal 10

    The patch solves the problem in my case.

    Cheers!

Production build 0.71.5 2024