Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP fatal error potentially related to ATF and picture tags #6661

Closed
joejoe04 opened this issue May 24, 2024 · 4 comments · Fixed by #7254
Closed

PHP fatal error potentially related to ATF and picture tags #6661

joejoe04 opened this issue May 24, 2024 · 4 comments · Fixed by #7254
Assignees
Labels
module: OCI Optimize Critical Images needs: environment needs: r&d Needs research and development (R&D) before a solution can be proposed and scoped. priority: medium Issues which are important, but no one will go out of business. severity: major Feature is not working as expected and no work around available type: bug Indicates an unexpected problem or unintended behavior
Milestone

Comments

@joejoe04
Copy link

joejoe04 commented May 24, 2024

Before submitting an issue please check that you’ve completed the following steps:

  • Made sure you’re on the latest version ✅
  • Used the search feature to ensure that the bug hasn’t been reported before ✅

Describe the bug
After upgrading to version 3.16, user reported site went down and the following error was logged:

"PHP Fatal error: Uncaught TypeError: ltrim(): Argument #1 ($string) must be of type string, null given in /www/creatureartteacherlive_491/public/wp-content/plugins/wp-rocket/inc/Engine/Media/AboveTheFold/Frontend/Controller.php:222 Stack trace: #0 /www/creatureartteacherlive_491/public/wp-content/plugins/wp-rocket/inc/Engine/Media/AboveTheFold/Frontend/Controller.php(222): ltrim(NULL, '/') #1 [internal function]: WP_Rocket\Engine\Media\AboveTheFold\Frontend\Controller->WP_Rocket\Engine\Media\AboveTheFold\Frontend\{closure}(false) #2 /www/creatureartteacherlive_491/public/wp-content/plugins/wp-rocket/inc/Engine/Media"

In the Slack discussion, Remy said he thought it may be related to:

  • how the <picture> tag is being handled.
  • Safeguards related to handling exclusions

Expected behavior
The error should not occur for all valid <picture> tag markup.

Additional context
Ticket - https://secure.helpscout.net/conversation/2605875796/493242/
Website - https://creatureartteacher.com
Slack - https://wp-media.slack.com/archives/C43T1AYMQ/p1716485105461249

Acceptance Criteria (for WP Media team use only)
Clear instructions for developers, to be added before the grooming

@piotrbak piotrbak added type: bug Indicates an unexpected problem or unintended behavior priority: medium Issues which are important, but no one will go out of business. needs: r&d Needs research and development (R&D) before a solution can be proposed and scoped. severity: major Feature is not working as expected and no work around available needs: environment labels May 27, 2024
@pavel-burminsky
Copy link

Hello,

We have the same problem on our client's website, here is an example https://www.escoffier.edu/about/chef-instructors/albert-schmid/. Is it possible to get it fixed?

@piotrbak piotrbak added the module: OCI Optimize Critical Images label Jul 15, 2024
@joejoe04
Copy link
Author

@Khadreal
Copy link
Contributor

Scope a solution ✅

We need to safeguard exclusion for empty path or path that aren't valid.
Before the return here we can add a check for the $exclusion['path'] if it's set.

if ( isset( $exclusion['path'] ) && is_string( $exclusion['path'] ) ) {
      return ltrim( $parsed_url['path'], '/' );
}
//Return empty string if not set.
return '';

Estimate the effort

Effort XS

@Miraeld
Copy link
Contributor

Miraeld commented Jan 28, 2025

Looks ok to me

@Miraeld Miraeld self-assigned this Jan 28, 2025
@Mai-Saad Mai-Saad self-assigned this Feb 5, 2025
@piotrbak piotrbak added this to the 3.18.2 milestone Feb 5, 2025
github-merge-queue bot pushed a commit that referenced this issue Feb 14, 2025
Co-authored-by: Khadreal <opeyemi.khadri@gmail.com>
Co-authored-by: WordPressFan <ahmed@wp-media.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: OCI Optimize Critical Images needs: environment needs: r&d Needs research and development (R&D) before a solution can be proposed and scoped. priority: medium Issues which are important, but no one will go out of business. severity: major Feature is not working as expected and no work around available type: bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants