[pkg-php-pear] Bug#1128313: php-console-commandline: Failing autopkgtests with PHP 8.5
Renan Rodrigo
rr at ubuntu.com
Wed Feb 18 02:12:24 GMT 2026
Package: php-console-commandline
Version: 1.2.6-1
Severity: normal
X-Debbugs-Cc: rr at ubuntu.com
Dear Maintainer,
php-console-commandline v1.2.6-1 autopkgtests fail when running with PHP
8.5. The diff for the failing tests don't say much:
FAIL [12/53] Test for Console_CommandLine::addOption() method (errors 5).[/tmp/autopkgtest.bpChUz/build.19f/real-tree/tests/console_commandline_addoption_errors_5.phpt]
========DIFF========
002+ Stack trace:
003+ #0 /usr/share/php/Console/CommandLine.php(855): trigger_error()
004+ #1 /usr/share/php/Console/CommandLine/Option.php(308): Console_CommandLine::triggerError()
005+ #2 /usr/share/php/Console/CommandLine.php(646): Console_CommandLine_Option->validate()
006+ #3 /tmp/autopkgtest.bpChUz/build.19f/real-tree/tests/console_commandline_addoption_errors_5.php(6): Console_CommandLine->addOption()
007+ #4 {main}
========DONE========
trigger_error is using E_USER_ERROR, which is deprecated, and that seems
to be the cause of the failures.
I have applied the following patch in Ubuntu, which resolves the
situation by throwing actual exceptions:
--- a/Console/CommandLine.php
+++ b/Console/CommandLine.php
@@ -826,8 +826,7 @@
{
if (!isset(self::$actions[$name])) {
if (!class_exists($class)) {
- self::triggerError('action_class_does_not_exists',
- E_USER_ERROR,
+ self::throwException('action_class_does_not_exists',
array('{$name}' => $name, '{$class}' => $class));
}
self::$actions[$name] = array($class, false);
@@ -835,27 +834,24 @@
}
// }}}
- // triggerError() {{{
+ // throwException() {{{
/**
- * A wrapper for programming errors triggering.
+ * A wrapper for programming Exception throwing.
*
* @param string $msgId Identifier of the message
- * @param int $level The php error level
* @param array $params An array of search=>replaces entries
*
* @return void
- * @todo remove Console::triggerError() and use exceptions only
*/
- public static function triggerError($msgId, $level, $params=array())
+ public static function throwException($msgId, $params=array())
{
+ $msg = 'unknown error';
if (isset(self::$errors[$msgId])) {
$msg = str_replace(array_keys($params),
array_values($params), self::$errors[$msgId]);
- trigger_error($msg, $level);
- } else {
- trigger_error('unknown error', $level);
}
+ throw new \Exception($msg);
}
// }}}
--- a/tests/console_commandline_addargument.phpt
+++ b/tests/console_commandline_addargument.phpt
@@ -112,4 +112,4 @@
}
}
-Fatal error: argument name must be a valid php variable name (got: Some invalid name) in %sCommandLine.php on line %d
+Fatal error: Uncaught Exception: argument name must be a valid php variable name (got: Some invalid name) in %sCommandLine.php on line %d
--- a/tests/console_commandline_addargument_2.phpt
+++ b/tests/console_commandline_addargument_2.phpt
@@ -25,4 +25,4 @@
?>
--EXPECTF--
foo bar
-Fatal error: only optional arguments can have a default value in %sCommandLine.php on line %d
+Fatal error: Uncaught Exception: only optional arguments can have a default value in %sCommandLine.php on line %d
--- a/tests/console_commandline_addoption_errors_1.phpt
+++ b/tests/console_commandline_addoption_errors_1.phpt
@@ -11,4 +11,4 @@
?>
--EXPECTF--
-Fatal error: option name must be a valid php variable name (got: Some invalid name) in %sCommandLine.php on line %d
+Fatal error: Uncaught Exception: option name must be a valid php variable name (got: Some invalid name) in %sCommandLine.php on line %d
--- a/tests/console_commandline_addoption_errors_2.phpt
+++ b/tests/console_commandline_addoption_errors_2.phpt
@@ -11,4 +11,4 @@
?>
--EXPECTF--
-Fatal error: you must provide at least an option short name or long name for option "name" in %sCommandLine.php on line %d
+Fatal error: Uncaught Exception: you must provide at least an option short name or long name for option "name" in %sCommandLine.php on line %d
--- a/tests/console_commandline_addoption_errors_3.phpt
+++ b/tests/console_commandline_addoption_errors_3.phpt
@@ -11,4 +11,4 @@
?>
--EXPECTF--
-Fatal error: option "name" short name must be a dash followed by a letter (got: "d") in %sCommandLine.php on line %d
+Fatal error: Uncaught Exception: option "name" short name must be a dash followed by a letter (got: "d") in %sCommandLine.php on line %d
--- a/tests/console_commandline_addoption_errors_4.phpt
+++ b/tests/console_commandline_addoption_errors_4.phpt
@@ -11,4 +11,4 @@
?>
--EXPECTF--
-Fatal error: option "name" long name must be 2 dashes followed by a word (got: "d") in %sCommandLine.php on line %d
+Fatal error: Uncaught Exception: option "name" long name must be 2 dashes followed by a word (got: "d") in %sCommandLine.php on line %d
--- a/tests/console_commandline_addoption_errors_5.phpt
+++ b/tests/console_commandline_addoption_errors_5.phpt
@@ -11,4 +11,4 @@
?>
--EXPECTF--
-Fatal error: invalid action for option "name". in %sCommandLine.php on line %d
+Fatal error: Uncaught Exception: invalid action for option "name". in %sCommandLine.php on line %d
--- a/tests/console_commandline_addoption_errors_6.phpt
+++ b/tests/console_commandline_addoption_errors_6.phpt
@@ -11,4 +11,4 @@
?>
--EXPECTF--
-Fatal error: unregistered action "Inexistant" for option "name". in %sCommandLine.php on line %d
+Fatal error: Uncaught Exception: unregistered action "Inexistant" for option "name". in %sCommandLine.php on line %d
--- a/tests/console_commandline_addoption_errors_7.phpt
+++ b/tests/console_commandline_addoption_errors_7.phpt
@@ -11,4 +11,4 @@
?>
--EXPECTF--
-Fatal error: you must provide a valid callback for option "name" in %sCommandLine.php on line %d
+Fatal error: Uncaught Exception: you must provide a valid callback for option "name" in %sCommandLine.php on line %d
--- a/tests/console_commandline_fromxmlfile_error.phpt
+++ b/tests/console_commandline_fromxmlfile_error.phpt
@@ -16,4 +16,4 @@
?>
--EXPECTF--
-Fatal error: XML definition file "%sunexisting.xml" does not exists or is not readable in %sCommandLine.php on line %d
+Fatal error: Uncaught Exception: XML definition file "%sunexisting.xml" does not exists or is not readable in %sCommandLine.php on line %d
--- a/Console/CommandLine/Argument.php
+++ b/Console/CommandLine/Argument.php
@@ -83,16 +83,14 @@
// check if the argument name is valid
if (!preg_match('/^[a-zA-Z_\x7f-\xff]+[a-zA-Z0-9_\x7f-\xff]*$/',
$this->name)) {
- Console_CommandLine::triggerError(
+ Console_CommandLine::throwException(
'argument_bad_name',
- E_USER_ERROR,
array('{$name}' => $this->name)
);
}
if (!$this->optional && $this->default !== null) {
- Console_CommandLine::triggerError(
- 'argument_no_default',
- E_USER_ERROR
+ Console_CommandLine::throwException(
+ 'argument_no_default'
);
}
parent::validate();
--- a/Console/CommandLine/XmlParser.php
+++ b/Console/CommandLine/XmlParser.php
@@ -54,8 +54,8 @@
public static function parse($xmlfile)
{
if (!is_readable($xmlfile)) {
- Console_CommandLine::triggerError('invalid_xml_file',
- E_USER_ERROR, array('{$file}' => $xmlfile));
+ Console_CommandLine::throwException('invalid_xml_file',
+ array('{$file}' => $xmlfile));
}
$doc = new DomDocument();
$doc->load($xmlfile);
@@ -117,9 +117,9 @@
return $doc->relaxNGValidate($path);
}
}
- Console_CommandLine::triggerError(
+ Console_CommandLine::throwException(
'invalid_xml_file',
- E_USER_ERROR, array('{$file}' => $rngfile));
+ array('{$file}' => $rngfile));
}
// }}}
--- a/Console/CommandLine/Option.php
+++ b/Console/CommandLine/Option.php
@@ -275,21 +275,21 @@
// check if the option name is valid
if (!preg_match('/^[a-zA-Z_\x7f-\xff]+[a-zA-Z0-9_\x7f-\xff]*$/',
$this->name)) {
- Console_CommandLine::triggerError('option_bad_name',
- E_USER_ERROR, array('{$name}' => $this->name));
+ Console_CommandLine::throwException('option_bad_name',
+ array('{$name}' => $this->name));
}
// call the parent validate method
parent::validate();
// a short_name or a long_name must be provided
if ($this->short_name == null && $this->long_name == null) {
- Console_CommandLine::triggerError('option_long_and_short_name_missing',
- E_USER_ERROR, array('{$name}' => $this->name));
+ Console_CommandLine::throwException('option_long_and_short_name_missing',
+ array('{$name}' => $this->name));
}
// check if the option short_name is valid
if ($this->short_name != null &&
!(preg_match('/^\-[a-zA-Z]{1}$/', $this->short_name))) {
- Console_CommandLine::triggerError('option_bad_short_name',
- E_USER_ERROR, array(
+ Console_CommandLine::throwException('option_bad_short_name',
+ array(
'{$name}' => $this->name,
'{$short_name}' => $this->short_name
));
@@ -297,28 +297,28 @@
// check if the option long_name is valid
if ($this->long_name != null &&
!preg_match('/^\-\-[a-zA-Z]+[a-zA-Z0-9_\-]*$/', $this->long_name)) {
- Console_CommandLine::triggerError('option_bad_long_name',
- E_USER_ERROR, array(
+ Console_CommandLine::throwException('option_bad_long_name',
+ array(
'{$name}' => $this->name,
'{$long_name}' => $this->long_name
));
}
// check if we have a valid action
if (!is_string($this->action)) {
- Console_CommandLine::triggerError('option_bad_action',
- E_USER_ERROR, array('{$name}' => $this->name));
+ Console_CommandLine::throwException('option_bad_action',
+ array('{$name}' => $this->name));
}
if (!isset(Console_CommandLine::$actions[$this->action])) {
- Console_CommandLine::triggerError('option_unregistered_action',
- E_USER_ERROR, array(
+ Console_CommandLine::throwException('option_unregistered_action',
+ array(
'{$action}' => $this->action,
'{$name}' => $this->name
));
}
// if the action is a callback, check that we have a valid callback
if ($this->action == 'Callback' && !is_callable($this->callback)) {
- Console_CommandLine::triggerError('option_invalid_callback',
- E_USER_ERROR, array('{$name}' => $this->name));
+ Console_CommandLine::throwException('option_invalid_callback',
+ array('{$name}' => $this->name));
}
}
I'm not sure this is actually the best way to deal with this, but the project
seems to be unmaintained upstream:
https://github.com/pear/Console_CommandLine/ was archived.
-- System Information:
Debian Release: trixie/sid
APT prefers noble-updates
APT policy: (500, 'noble-updates'), (500, 'noble-security'), (500, 'noble'), (100, 'noble-backports')
Architecture: amd64 (x86_64)
Kernel: Linux 6.17.0-14-generic (SMP w/22 CPU threads; PREEMPT)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
More information about the pkg-php-pear
mailing list