CodeIgniter4 icon indicating copy to clipboard operation
CodeIgniter4 copied to clipboard

Bug: Call to undefined method CodeIgniter\HTTP\CLIRequest::getGet()

Open thiagovieiradev opened this issue 3 years ago • 1 comments

PHP Version

7.4

CodeIgniter4 Version

4.2.3

CodeIgniter4 Installation Method

Composer (as dependency to an existing project)

Which operating systems have you tested for this bug?

Linux

Which server did you use?

apache

Database

Mysql

What happened?

Run php spark show follow error:

Type:        Error
Message:     Call to undefined method CodeIgniter\HTTP\CLIRequest::getGet()
Filename:    /var/www/bilhete/vendor/codeigniter4/framework/system/Debug/Toolbar.php
Line Number: 452

        Backtrace:
                                                -44 - /var/www/bilhete/app/Config/Events.php::respond
                                                                -149 - /var/www/bilhete/vendor/codeigniter4/framework/system/Events/Events.php::Config\{closure}
                                                                -317 - /var/www/bilhete/vendor/codeigniter4/framework/system/CodeIgniter.php::trigger
                                                                -48 - /var/www/bilhete/vendor/codeigniter4/framework/system/CLI/Console.php::run
                                                                -98 - /var/www/bilhete/spark::run`

Steps to Reproduce

Run php spark in root

Expected Output

php spark command

Anything else?

No response

thiagovieiradev avatar Aug 10 '22 00:08 thiagovieiradev

What command did you run?

kenjis avatar Aug 10 '22 01:08 kenjis

What command did you run?

php spark

thiagovieiradev avatar Aug 10 '22 10:08 thiagovieiradev

Cannot reproduce.

$ ci4-install.php ci423 4.2.3
$ cd ci423/
$ php spark

CodeIgniter v4.2.3 Command Line Tool - Server Time: 2022-08-10 05:45:41 UTC-05:00

Cache
  cache:clear        Clears the current system caches.
  cache:info         Shows file cache information in the current system.

CodeIgniter
  env                Retrieves the current environment, or set a new one.
  help               Displays basic usage information.
  list               Lists the available commands.
  namespaces         Verifies your namespaces are setup correctly.
  publish            Discovers and executes all predefined Publisher classes.
  routes             Displays all routes.
  serve              Launches the CodeIgniter PHP-Development Server.

Database
  db:create          Create a new database schema.
  db:seed            Runs the specified seeder to populate known data into the database.
  db:table           Retrieves information on the selected table.
  migrate            Locates and runs all new migrations against the database.
  migrate:refresh    Does a rollback followed by a latest to refresh the current state of the database.
  migrate:rollback   Runs the "down" method for all migrations in the last batch.
  migrate:status     Displays a list of all migrations and whether they've been run or not.

Encryption
  key:generate       Generates a new encryption key and writes it in an `.env` file.

Generators
  make:command       Generates a new spark command.
  make:config        Generates a new config file.
  make:controller    Generates a new controller file.
  make:entity        Generates a new entity file.
  make:filter        Generates a new filter file.
  make:migration     Generates a new migration file.
  make:model         Generates a new model file.
  make:scaffold      Generates a complete set of scaffold files.
  make:seeder        Generates a new seeder file.
  make:validation    Generates a new validation file.
  migrate:create     [DEPRECATED] Creates a new migration file. Please use "make:migration" instead.
  session:migration  [DEPRECATED] Generates the migration file for database sessions, Please use  "make:migration --session"
                     instead.

Housekeeping
  debugbar:clear     Clears all debugbar JSON files.
  logs:clear         Clears all log files.

kenjis avatar Aug 10 '22 10:08 kenjis

I updated version 4.1.9 to 4.2.3. After that, this error happens. However, now I installed a clean version in another folder, and php spark worked perfectly. I conclude that it must be something in my installation.

thiagovieiradev avatar Aug 10 '22 11:08 thiagovieiradev

Check the upgrade guide: https://codeigniter4.github.io/CodeIgniter4/installation/upgrading.html

kenjis avatar Aug 10 '22 11:08 kenjis

I also have this issue after updating to the latest version.

Before updating, filters wouldn't get executed when calling a controller from the CLI. After updating, Honeypot, Toolbar etc. are executed (and failing).

Call to undefined method CodeIgniter\HTTP\CLIRequest::getPost()

I think it can also be caused by the following change in 4.2.2:

Now Services::request() returns IncomingRequest or CLIRequest

NSURLSession0 avatar Aug 20 '22 18:08 NSURLSession0

i fix it by replace App/Config/Events.php with latest (there some change in code)

ikesela avatar Aug 21 '22 16:08 ikesela

i fix it by replace App/Config/Events.php with latest (there some change in code)

My App/Config/Events.php was already up to date unfortunately. So that won't fix the issue.

For now I reset the filters in app/Config/Filters.php, but this is not a real solution of course.

public function __construct()
{
    // Do not use filters in CLI
    if ($isCLI = php_sapi_name() == 'cli') {
        $this->globals = [];
        parent::__construct();
    }
}

NSURLSession0 avatar Aug 22 '22 19:08 NSURLSession0