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

Fixes #6690 Prevent type error if preg_replace() returns null #6691

Merged
merged 1 commit into from
Jun 5, 2024

Conversation

Tabrisrp
Copy link
Contributor

@Tabrisrp Tabrisrp commented Jun 3, 2024

Description

Fixes #6690

Documentation

Technical documentation

preg_replace can return null` when there is an error, and if we use the value after, it will cause a fatal error due to passing an incorrect type.

Adding a guard clause prevents the issue.

Type of change

  • Bug fix (non-breaking change which fixes an issue).

Checklists

Feature validation

  • I validated all the Acceptance Criteria. If possible, provide sreenshots or videos.
  • I triggered all changed lines of code at least once without new errors/warnings/notices.
  • I implemented built-in tests to cover the new/changed code.

Code style

  • I wrote self-explanatory code about what it does.
  • I wrote comments to explain why it does it.
  • I named variables and functions explicitely.
  • I protected entry points against unexpected inputs.
  • I did not introduce unecessary complexity.

@Tabrisrp Tabrisrp requested a review from a team June 3, 2024 19:35
@Tabrisrp Tabrisrp self-assigned this Jun 3, 2024
@Tabrisrp Tabrisrp added type: bug Indicates an unexpected problem or unintended behavior lcp labels Jun 3, 2024
Copy link

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
Report missing for 60749b71 66.67% (target: 50.00%)
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (60749b7) Report Missing Report Missing Report Missing
Head commit (cb8762c) 37239 14403 38.68%

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#6691) 6 4 66.67%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Codacy will stop sending the deprecated coverage status from June 5th, 2024. Learn more

Footnotes

  1. Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

Copy link

@hanna-meda hanna-meda left a comment

Choose a reason for hiding this comment

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

As the error is hard to trigger, we ran a smoke test on preloading LCP + clear critical images. No error was encountered.
We'll monitor this also during Test Run execution for 3.16.1 prerelease.

@hanna-meda hanna-meda added this pull request to the merge queue Jun 5, 2024
Merged via the queue into develop with commit 4f2109a Jun 5, 2024
13 checks passed
@hanna-meda hanna-meda deleted the fix/6690-type-error branch June 5, 2024 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PHP fatal error potentially related to ATF / Critical Images Optimization and preg_replace
3 participants