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 #6887 Check for string to handle null return from get_permalink() #6996

Merged
merged 3 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion inc/Engine/Common/PerformanceHints/Admin/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ private function delete_rows() {
public function delete_post( $post_id ) {
$url = get_permalink( $post_id );

if ( false === $url ) {
// get_permalink should return false or string, but some plugins return null.
if ( ! is_string( $url ) ) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Regex implements ProcessorInterface {
*
* @var array
*/
private $exclusions;
private $exclusions; // @phpstan-ignore-line

/**
* Sets the exclusions list
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class SimpleHtmlDom implements ProcessorInterface {
*
* @var array
*/
private $exclusions;
private $exclusions; // @phpstan-ignore-line

/**
* Sets the exclusions list
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
],
'expected' => false,
],
'testShoulDoNothingURLNull' => [
'config' => [
'filter' => true,
'post_id' => 1,
'url' => null,
],
'expected' => false,
],
'testShoulDoNothingURLFalse' => [
'config' => [
'filter' => true,
Expand Down
Loading