Skip to content
Open
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
1 change: 0 additions & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ includes:
- tests/phpstan/baselines/function.alreadyNarrowedType.neon
- tests/phpstan/baselines/function.impossibleType.neon
- tests/phpstan/baselines/function.resultUnused.neon
- tests/phpstan/baselines/greater.invalid.neon
- tests/phpstan/baselines/greaterOrEqual.alwaysTrue.neon
- tests/phpstan/baselines/identical.alwaysFalse.neon
- tests/phpstan/baselines/identical.alwaysTrue.neon
Expand Down
6 changes: 0 additions & 6 deletions src/wp-admin/includes/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2046,12 +2046,6 @@ function upgrade_430_fix_comments() {
'type' => 'byte',
'length' => 65535,
);
} elseif ( ! is_array( $content_length ) ) {
$length = (int) $content_length > 0 ? (int) $content_length : 65535;
$content_length = array(
'type' => 'byte',
'length' => $length,
);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

it seems like this function was written when get_col_length() could return a string, and then was moved in 1cccb02 and stuck around even though get_col_length() was changed in 2ce97b2 to never return a string. this dangled on unused.

to that end it seems like this should be safe to remove.

that being said, if we remove it we make the code fragile, because we remove a runtime-enforced type constraint with a source-time assumption about it. if get_col_length() changes again as it changed in the past, this could lead to a crash on property access of a non-array.

the original code would have been clearer as if ( is_string() ) than if ( ! is_array() ), but we could potentially remove this and leave the safety.

} elseif ( ! is_array( $content_length ) ) {
	return;
}

PHPStan might still complain, but avoiding crashes is more important than making the linter gods happy

}

if ( 'byte' !== $content_length['type'] || 0 === $content_length['length'] ) {
Expand Down
25 changes: 0 additions & 25 deletions tests/phpstan/baselines/greater.invalid.neon

This file was deleted.

Loading