Skip to content

Commit 6af4b97

Browse files
author
dmsnell
committed
Code Quality: Resolve greater.invalid PHPStan errors in baseline.
Resolves type issues in `upgrade_430_fix_comments()`, which checks for a string return from `$wpdb->get_col_length()`, which was removed from Core in r32364. This change was part of Contributor Day at WordCamp US 2026. Developed in: WordPress#13080 Discussed in: https://core.trac.wordpress.org/ticket/65817 Follow-up to [32364]. Props dpantazis, dmsnell. See #65817. git-svn-id: https://develop.svn.wordpress.org/trunk@63344 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 5ba7fb8 commit 6af4b97

3 files changed

Lines changed: 1 addition & 37 deletions

File tree

‎phpstan.neon.dist‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ includes:
4747
- tests/phpstan/baselines/function.alreadyNarrowedType.neon
4848
- tests/phpstan/baselines/function.impossibleType.neon
4949
- tests/phpstan/baselines/function.resultUnused.neon
50-
- tests/phpstan/baselines/greater.invalid.neon
5150
- tests/phpstan/baselines/greaterOrEqual.alwaysTrue.neon
5251
- tests/phpstan/baselines/identical.alwaysFalse.neon
5352
- tests/phpstan/baselines/identical.alwaysTrue.neon

‎src/wp-admin/includes/upgrade.php‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2037,24 +2037,14 @@ function upgrade_430_fix_comments() {
20372037

20382038
$content_length = $wpdb->get_col_length( $wpdb->comments, 'comment_content' );
20392039

2040-
if ( is_wp_error( $content_length ) ) {
2041-
return;
2042-
}
2043-
20442040
if ( false === $content_length ) {
20452041
$content_length = array(
20462042
'type' => 'byte',
20472043
'length' => 65535,
20482044
);
2049-
} elseif ( ! is_array( $content_length ) ) {
2050-
$length = (int) $content_length > 0 ? (int) $content_length : 65535;
2051-
$content_length = array(
2052-
'type' => 'byte',
2053-
'length' => $length,
2054-
);
20552045
}
20562046

2057-
if ( 'byte' !== $content_length['type'] || 0 === $content_length['length'] ) {
2047+
if ( ! is_array( $content_length ) || 'byte' !== $content_length['type'] || 0 === $content_length['length'] ) {
20582048
// Sites with malformed DB schemas are on their own.
20592049
return;
20602050
}
Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +0,0 @@
1-
# PHPStan baseline for the `greater.invalid` errors in WordPress core.
2-
#
3-
# https://phpstan.org/error-identifiers/greater.invalid
4-
#
5-
# Each entry is scoped to a single file and carries an exact occurrence count,
6-
# so that a new instance is reported as a new error rather than being absorbed
7-
# silently. Fixing an occurrence therefore means decrementing or removing its
8-
# entry here as part of the same change.
9-
#
10-
# The goal is to empty this file and delete it, along with the `includes` entry
11-
# for it in phpstan.neon.dist.
12-
#
13-
# Generated by `composer phpstan:baselines`. Do not edit by hand; regenerate with
14-
#
15-
# composer phpstan:baselines -- --identifier=greater.invalid
16-
#
17-
# which reruns the analysis with this file suppressed so the errors surface again.
18-
19-
parameters:
20-
ignoreErrors:
21-
-
22-
message: '#^Comparison operation "\>" between \*NEVER\* and 0 results in an error\.$#'
23-
identifier: greater.invalid
24-
count: 1
25-
path: ../../../src/wp-admin/includes/upgrade.php

0 commit comments

Comments
 (0)