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

picture and img-srcset have no src attribute in the database, making the front end optimization crash #6699

Closed
MathieuLamiot opened this issue Jun 5, 2024 · 1 comment · Fixed by #6700
Assignees
Milestone

Comments

@MathieuLamiot
Copy link
Contributor

Context
Following #6694 there is still a regression on develop for picture and img-srcset LCP/ATF.
The issue is that they can be saved in DB without the src attribute, creating a fatal:

[05-Jun-2024 17:12:05 UTC] PHP Warning:  Undefined property: stdClass::$src in /var/www/html/mathieu.e2e.rocketlabsqa.ovh/wp-content/plugins/wp-rocket/inc/Engine/Media/AboveTheFold/Frontend/Controller.php on line 155
[05-Jun-2024 17:12:05 UTC] PHP Fatal error:  Uncaught TypeError: preg_quote(): Argument #1 ($str) must be of type string, null given in /var/www/html/mathieu.e2e.rocketlabsqa.ovh/wp-content/plugins/wp-rocket/inc/Engine/Media/AboveTheFold/Frontend/Controller.php:155
Stack trace:
#0 /var/www/html/mathieu.e2e.rocketlabsqa.ovh/wp-content/plugins/wp-rocket/inc/Engine/Media/AboveTheFold/Frontend/Controller.php(155): preg_quote()
#1 /var/www/html/mathieu.e2e.rocketlabsqa.ovh/wp-content/plugins/wp-rocket/inc/Engine/Media/AboveTheFold/Frontend/Controller.php(119): WP_Rocket\Engine\Media\AboveTheFold\Frontend\Controller->set_fetchpriority()
#2 /var/www/html/mathieu.e2e.rocketlabsqa.ovh/wp-content/plugins/wp-rocket/inc/Engine/Media/AboveTheFold/Frontend/Controller.php(86): WP_Rocket\Engine\Media\AboveTheFold\Frontend\Controller->preload_lcp()
#3 /var/www/html/mathieu.e2e.rocketlabsqa.ovh/wp-content/plugins/wp-rocket/inc/Engine/Media/AboveTheFold/Frontend/Subscriber.php(46): WP_Rocket\Engine\Media\AboveTheFold\Frontend\Controller->lcp()
#4 /var/www/html/mathieu.e2e.rocketlabsqa.ovh/wp-includes/class-wp-hook.php(324): WP_Rocket\Engine\Media\AboveTheFold\Frontend\Subscriber->lcp()
#5 /var/www/html/mathieu.e2e.rocketlabsqa.ovh/wp-includes/plugin.php(205): WP_Hook->apply_filters()
#6 /var/www/html/mathieu.e2e.rocketlabsqa.ovh/wp-content/plugins/wp-rocket/inc/Engine/Optimization/Buffer/Optimization.php(100): apply_filters()
#7 [internal function]: WP_Rocket\Engine\Optimization\Buffer\Optimization->maybe_process_buffer()
#8 /var/www/html/mathieu.e2e.rocketlabsqa.ovh/wp-includes/functions.php(5373): ob_end_flush()
#9 /var/www/html/mathieu.e2e.rocketlabsqa.ovh/wp-includes/class-wp-hook.php(324): wp_ob_end_flush_all()
#10 /var/www/html/mathieu.e2e.rocketlabsqa.ovh/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
#11 /var/www/html/mathieu.e2e.rocketlabsqa.ovh/wp-includes/plugin.php(517): WP_Hook->do_action()
#12 /var/www/html/mathieu.e2e.rocketlabsqa.ovh/wp-includes/load.php(1260): do_action()
#13 [internal function]: shutdown_action_hook()
#14 {main}
  thrown in /var/www/html/mathieu.e2e.rocketlabsqa.ovh/wp-content/plugins/wp-rocket/inc/Engine/Media/AboveTheFold/Frontend/Controller.php on line 155

This is reproducible on this template: http://mathieu.e2e.rocketlabsqa.ovh/lcp_no_dimensions_picture
On 3.16, we have in the DB for Desktop LCP on this page:

{"type":"picture","src":"","sources":[{"srcset":"http:\/\/mathieu.e2e.rocketlabsqa.ovh\/wp-content\/rocket-test-data\/images\/lcp\/testavif.avif","media":"(min-width: 700px)"},{"srcset":"http:\/\/mathieu.e2e.rocketlabsqa.ovh\/wp-content\/rocket-test-data\/images\/lcp\/testPng.png","media":"(min-width: 450px)"}]}
On develop, the src attribute is missing.

Expected behavior
src attribute must always be set for an LCP/ATF object in the DB.
No Fatal related to missing $lcp->src must occur.

Acceptance Criteria

@MathieuLamiot MathieuLamiot self-assigned this Jun 5, 2024
@MathieuLamiot MathieuLamiot added this to the 3.16.1 milestone Jun 5, 2024
@MathieuLamiot MathieuLamiot linked a pull request Jun 5, 2024 that will close this issue
22 tasks
@MathieuLamiot MathieuLamiot removed their assignment Jun 5, 2024
@Mai-Saad
Copy link
Contributor

Mai-Saad commented Jun 6, 2024

Fixing this at e2e shall capture this kind of error wp-media/wp-rocket-e2e#98

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants