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

Don't include images without src attributes when gathering image info #21786

Conversation

leonidasmi
Copy link
Contributor

@leonidasmi leonidasmi commented Nov 4, 2024

Context

Summary

This PR can be summarized in the following changelog entry:

  • Fixes a bug where a deprecation message would appear in PHP 8+ when saving a post containing images with invalid sources. Props to kkmuffme.

Relevant technical choices:

Test instructions

Test instructions for the acceptance test before the PR gets merged

This PR can be acceptance tested by following these steps:

  • Easiest to test with classic editor, so switch to that
  • In the post HTML, add an image with no src attribute, eg. <img/>
  • Save the post and confirm you dont get a PHP Deprecated: htmlentities(): Passing null to parameter #1 ($string) of type string is deprecated in the debug.log
    • You would get one with the production plugin version.
  • Also, go to the SEO links database table and confim that there's no entry created with an empty URL column
    • You would get one such entry with the production version

Relevant test scenarios

  • Changes should be tested with the browser console open
  • Changes should be tested on different posts/pages/taxonomies/custom post types/custom taxonomies
  • Changes should be tested on different editors (Default Block/Gutenberg/Classic/Elementor/other)
  • Changes should be tested on different browsers
  • Changes should be tested on multisite

Test instructions for QA when the code is in the RC

  • QA should use the same steps as above.

QA can test this PR by following these steps:

Impact check

This PR affects the following parts of the plugin, which may require extra testing:

  • Create a post with 3 images.
  • Check the SEO links database table and confirm that you get the three respective entries for those images
  • Reset indexables and try the same with the production plugin version
  • Compare the entries created with this RC/PR and production plugin version

UI changes

  • This PR changes the UI in the plugin. I have added the 'UI change' label to this PR.

Other environments

  • This PR also affects Shopify. I have added a changelog entry starting with [shopify-seo], added test instructions for Shopify and attached the Shopify label to this PR.

Documentation

  • I have written documentation for this change. For example, comments in the Relevant technical choices, comments in the code, documentation on Confluence / shared Google Drive / Yoast developer portal, or other.

Quality assurance

  • I have tested this code to the best of my abilities.
  • During testing, I had activated all plugins that Yoast SEO provides integrations for.
  • I have added unit tests to verify the code works as intended.
  • If any part of the code is behind a feature flag, my test instructions also cover cases where the feature flag is switched off.
  • I have written this PR in accordance with my team's definition of done.
  • I have checked that the base branch is correctly set.

Innovation

  • No innovation project is applicable for this PR.
  • This PR falls under an innovation project. I have attached the innovation label.
  • I have added my hours to the WBSO document.

Fixes E_DEPRECATED: htmlentities(): Passing null to parameter #1 ($string) of type string is deprecated

@coveralls
Copy link

coveralls commented Nov 4, 2024

Pull Request Test Coverage Report for Build de41164f0879a9dd3a0c49eab159ad70bd91d020

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 4 (0.0%) changed or added relevant lines in 1 file are covered.
  • 606 unchanged lines in 12 files lost coverage.
  • Overall coverage increased (+0.009%) to 54.663%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/images/Application/image-content-extractor.php 0 4 0.0%
Files with Coverage Reduction New Missed Lines %
inc/class-post-type.php 2 89.47%
src/integrations/blocks/abstract-dynamic-block-v3.php 5 0.0%
src/presenters/breadcrumbs-presenter.php 5 93.9%
src/presenters/url-list-presenter.php 11 0.0%
src/helpers/options-helper.php 12 20.0%
src/integrations/admin/first-time-configuration-integration.php 27 0.0%
inc/class-rewrite.php 30 56.32%
admin/filters/class-abstract-post-filter.php 31 0.0%
inc/options/class-wpseo-options.php 50 46.35%
wp-seo-main.php 57 0.0%
Totals Coverage Status
Change from base Build cbce7c227a089736ff8ddf1e3dca02a455184172: 0.009%
Covered Lines: 29706
Relevant Lines: 54643

💛 - Coveralls

@leonidasmi leonidasmi added the changelog: bugfix Needs to be included in the 'Bugfixes' category in the changelog label Nov 4, 2024
@leonidasmi leonidasmi marked this pull request as ready for review November 4, 2024 09:38
@vraja-pro
Copy link
Contributor

Added a test for that change.
CR & AC ✅

@vraja-pro vraja-pro force-pushed the 21737-e_deprecated-htmlentities-passing-null-to-parameter-1-string-of-type-string-is-deprecated branch from beb8f9c to 9898745 Compare November 19, 2024 12:34
@vraja-pro vraja-pro changed the base branch from trunk to feature/plugin-fixes November 20, 2024 08:19
@vraja-pro vraja-pro added this to the feature/plugin-fixes milestone Nov 20, 2024
@enricobattocchi enricobattocchi changed the base branch from feature/plugin-fixes to trunk December 6, 2024 11:10
@enricobattocchi enricobattocchi removed this from the feature/plugin-fixes milestone Dec 6, 2024
@pls78 pls78 added this to the 24.2 milestone Dec 9, 2024
@pls78 pls78 merged commit e4367fd into trunk Dec 9, 2024
23 checks passed
@pls78 pls78 deleted the 21737-e_deprecated-htmlentities-passing-null-to-parameter-1-string-of-type-string-is-deprecated branch December 9, 2024 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: bugfix Needs to be included in the 'Bugfixes' category in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

E_DEPRECATED: htmlentities(): Passing null to parameter #1 ($string) of type string is deprecated
5 participants