Welcome Guest, Not a member yet? Register   Sign In
Spark command not working in controller after upgrade to CI 4.5.2
#11

(This post was last modified: 06-22-2024, 03:45 AM by InsiteFX.)

I'm using Laragon with apache 2.4.59-240605 & MySQL 8.3 PHP 8.3 CI 4.5.2

I switched to Laragon because XAMPP is not being updated that much any more.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#12

(06-22-2024, 02:16 AM)kenjis Wrote: This code is invalid.
PHP Code:
log_message('after''before service(commands)'); 

There is no log level `after`.
https://codeigniter.com/user_guide/gener...og_message

Yeah, that's obviously a typo, but that line was never executed anyway. It should have read:
 
PHP Code:
log_message('debug''after service(commands)'); 
Reply
#13

So after more debugging, I lucked into finding the problem.

It seems CodeIgniter\CLI\Commands->discoverCommands() was loading vendor\codeigniter4\framework\system\Commands\Server\rewrite.php

This caused it to rewrite to localhost anytime command() was called within a controller.

Delving into rewrite.php, I see that there is a check to not do the rewrite when in cli. However when running a cli command within a controller on xammp, PHP_SAPI is not 'cli' but 'apache2handler'.

So if I crudely fix it as below, it works. I'm not sure what changes has been made since CI 4.4.6 that would result in this new behaviour? Can someone with more knowledge of the framework please check?

PHP Code:
// Avoid this file run when listing commands
if (PHP_SAPI === 'cli' || PHP_SAPI === 'apache2handler') {
    return;

Reply
#14

@jetspeed I have confirmed the behavior, and sent a PR to fix it.
Check https://github.com/codeigniter4/CodeIgniter4/pull/8995
Reply
#15

@jetspeed thank you!
Reply
#16

(06-24-2024, 12:55 AM)kenjis Wrote: @jetspeed I have confirmed the behavior, and sent a PR to fix it.
Check https://github.com/codeigniter4/CodeIgniter4/pull/8995
Thank you so much!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB