-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[BUG]: Register CLI application throwing warning #16186
Comments
Could please specify what is on line 283 in cli.php file? |
I've edited my previous post. //line 283
$console->handle($arguments); Thanks! |
@dz3n If possible can you also post the task you are trying to run? (the task class) as well as the command you are invoking in the CLI? |
I have the same problem. I solved it by always passing the second parameter, even though it's |
The task class doesn't matter really the command is as follow: without any If I change it with second param like this I don't get warnings, so @Alistar84 is right, I need to pass second argument in order to get rid of this error |
@dz3n I am having some trouble recreating this. First of all in your code you can make a small change so that you don't have to run each command with //cli.php
$console = new Console($container);
$arguments = [
'action' => 'main',
];
foreach ($argv as $k => $arg) {
if ($k === 1) {
$arguments['task'] = $arg;
} elseif ($k === 2) {
$arguments['action'] = $arg;
} elseif ($k >= 3) {
$arguments['params'][] = $arg;
}
}
$console->handle($arguments); Now for my test I am using the tasks in our testing suite. My <?php
declare(strict_types=1);
error_reporting(E_ALL);
ini_set("display_errors", 'On');
use Phalcon\Cli\Console;
use Phalcon\Cli\Dispatcher;
use Phalcon\Di\FactoryDefault\Cli as CliDI;
require_once 'vendor/autoload.php';
$container = new CliDI();
$dispatcher = new Dispatcher();
$dispatcher->setDefaultNamespace('Phalcon\Tests\Fixtures\Tasks');
$container->setShared('dispatcher', $dispatcher);
$console = new Console($container);
$arguments = [];
foreach ($argv as $k => $arg) {
if ($k === 1) {
$arguments['task'] = $arg;
} elseif ($k === 2) {
$arguments['action'] = $arg;
} elseif ($k >= 3) {
$arguments['params'][] = $arg;
}
}
try {
$console->handle($arguments);
} catch (\Exception $e) {
fwrite(STDERR, $e->getMessage() . PHP_EOL);
exit(1);
} catch (Throwable $throwable) {
fwrite(STDERR, $throwable->getMessage() . PHP_EOL);
exit(1);
} Then I run (in a localr docker environment) php -d extension=ext/modules/phalcon.so aa.php params This executes the Action 'main' was not found in handler 'params' If I run it for the
|
I am not sure why this happens and I cannot get this to replicate. Feel free to email me directly (nikos@phalcon.io) so that we can arrange some sort of screen sharing to figure this out. Alternatively, if this is not feasible, have a look above for any changes between my code and yours and let me know. |
@dz3n never mind I managed to reproduce it |
Describe the bug
Throwing deprecated warning
To Reproduce
Based on documentation, to register CLI application code like this is required:
Which cause this kind of warning
Deprecated: Phalcon\Dispatcher\AbstractDispatcher::setActionName(): Passing null to parameter #1 ($actionName) of type string is deprecated in /var/www/application/apps/crontabs/cli.php on line 283
Details
The text was updated successfully, but these errors were encountered: