Open
Conversation
# Upstream PR notes — wirecli/wire-cli v1.4.13 Two small bugs found while running v1.4.13 against a ProcessWire 3.0.244 install on PHP 8.3. The first is a **hard blocker** for `field:list` (no command-line invocation succeeds), the second is a deprecation warning that becomes a fatal error on PHP 8.4. Both have been patched locally in `/home/echo/.composer/vendor/wirecli/wire-cli/`. Patches will be lost by `composer global update` — re-apply if needed. --- ## Bug 1 — `field:list` always throws `TypeError` **Severity:** Blocker — every invocation of `wirecli field:list` (with or without options) errors out before printing anything. **Affected file:** `src/Commands/Field/FieldListCommand.php` **Reproduce:** ```bash cd /path/to/processwire-root wirecli field:list # or wirecli field:list --all wirecli field:list --type=Email wirecli field:list --tag=foo ``` **Result on PHP 8.1+ / 8.3 / 8.4:** ``` TypeError: count(): Argument wirecli#1 ($value) must be of type Countable|array, int given in src/Commands/Field/FieldListCommand.php:58 Stack trace: #0 src/Commands/Field/FieldListCommand.php(58): count(99) wirecli#1 vendor/symfony/console/Command/Command.php(326): …->execute(…) … ``` **Cause:** `getData()` returns an object whose `->count` property is the **integer** total of matched fields: ```php return (object) array('count' => $count, 'content' => $content); ``` …but `execute()` then does: ```php if (count($data->count) > 0) { ``` `count()` on a scalar was a `WARNING` in PHP 7.2 and a `TypeError` since PHP 8.0, so this branch can never run. **Fix (1-character logic change):** ```diff - if (count($data->count) > 0) { + if ($data->count > 0) { ``` (Or equivalently `if (!empty($data->content))`.) **Verified after fix:** ```text $ wirecli field:list | tail -2 (89 in set, total: 89) $ wirecli field:list --all | tail -2 (99 in set, total: 99) $ wirecli field:list --type=Email | tail -2 (1 in set, total: 1) ``` --- ## Bug 2 — `preg_match()` deprecation when iterating modules **Severity:** Deprecation warning under PHP 8.1+; promoted to a hard error in PHP 8.4 (`null` no longer auto-coerces to string for internal functions). **Affected files (same one-character fix in each):** - `src/Commands/Field/FieldListCommand.php:50` - `src/Commands/Field/FieldTypesCommand.php:41` - `src/Commands/Field/FieldCreateCommand.php:94` **Reproduce:** ```bash wirecli field:types ``` **Result:** ``` Deprecated: preg_match(): Passing null to parameter wirecli#2 ($subject) of type string is deprecated in src/Commands/Field/FieldTypesCommand.php on line 41 ``` **Cause:** When iterating `\ProcessWire\wire('modules')` some module info entries (e.g. uninstalled placeholders) return `null` for `->name` rather than a string, and `preg_match()` can no longer accept `null`. **Fix (cast to string):** ```diff - if (preg_match('/^Fieldtype/', $module->name)) { + if (preg_match('/^Fieldtype/', (string)$module->name)) { ``` Apply the same change to the three files above. **Optional cleanup in `FieldListCommand`:** the `$fieldtypes` array (lines 48–53) is collected but never read anywhere in the file — likely dead code from an earlier revision. Worth removing in the same PR if you want, otherwise leave it (the cast above is enough to silence the deprecation). --- ## Suggested PR shape Either one combined PR (`Fix field:list TypeError and PHP 8.1+ preg_match deprecations`) with two commits, or two separate small PRs: 1. `fix(field:list): use scalar comparison instead of count() on int` — Bug 1 2. `fix(field): cast $module->name to string before preg_match` — Bug 2 (×3 files) Both are tiny, test-by-running fixes — no behaviour change beyond making the affected commands actually run. --- ## Environment - wirecli `v1.4.13` (composer global, package `wirecli/wire-cli`) - ProcessWire `3.0.244` - PHP `8.3.x` (also reproduced reasoning under 8.4 behaviour) - OS: Linux (RHEL 10 family)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Upstream PR notes — wirecli/wire-cli v1.4.13
Cursor found a bug and helpfully wrote a detailed note below:
Two small bugs found while running v1.4.13 against a ProcessWire 3.0.244 install on PHP 8.3. The first is a hard blocker for
field:list(no command-line invocation succeeds), the second is a deprecation warning that becomes a fatal error on PHP 8.4.Both have been patched locally in
/home/echo/.composer/vendor/wirecli/wire-cli/. Patches will be lost bycomposer global update— re-apply if needed.Bug 1 —
field:listalways throwsTypeErrorSeverity: Blocker — every invocation of
wirecli field:list(with or without options) errors out before printing anything.Affected file:
src/Commands/Field/FieldListCommand.phpReproduce:
Result on PHP 8.1+ / 8.3 / 8.4:
Cause:
getData()returns an object whose->countproperty is the integer total of matched fields:…but
execute()then does:count()on a scalar was aWARNINGin PHP 7.2 and aTypeErrorsince PHP 8.0, so this branch can never run.Fix (1-character logic change):
(Or equivalently
if (!empty($data->content)).)Verified after fix:
Bug 2 —
preg_match()deprecation when iterating modulesSeverity: Deprecation warning under PHP 8.1+; promoted to a hard error in PHP 8.4 (
nullno longer auto-coerces to string for internal functions).Affected files (same one-character fix in each):
src/Commands/Field/FieldListCommand.php:50src/Commands/Field/FieldTypesCommand.php:41src/Commands/Field/FieldCreateCommand.php:94Reproduce:
Result:
Cause: When iterating
\ProcessWire\wire('modules')some module info entries (e.g. uninstalled placeholders) returnnullfor->namerather than a string, andpreg_match()can no longer acceptnull.Fix (cast to string):
Apply the same change to the three files above.
Optional cleanup in
FieldListCommand: the$fieldtypesarray (lines 48–53) is collected but never read anywhere in the file — likely dead code from an earlier revision. Worth removing in the same PR if you want, otherwise leave it (the cast above is enough to silence the deprecation).Environment
v1.4.13(composer global, packagewirecli/wire-cli)3.0.2448.3.x(also reproduced reasoning under 8.4 behaviour)