Cakephp 2.10.13 with PHP 7.2 CLI

As part of my effort to get to V3 with PHP 7.2, I decided a first step would be to get my existing 2.10.13 app running on PHP 7.2.

I had to change a few things but the app runs fine now on my Windows 10/xampp test system. I installed it on the live shared cpanel system and the web stuff runs fine.

However I experience a problem with code running via cli as a cron. Any console php code fails. Here is an example of what I get:-

Welcome to CakePHP v2.10.13 Console


App : app

Path: /home/probusgi/public_html/ProbusLive/app/


Warning Error: ini_set(): Headers already sent. You cannot change the session module’s ini settings at this time in [/home/probusgi/public_html/ProbusLive/lib/Cake/Model/Datasource/CakeSession.php, line 581]

Error: Unable to configure the session, setting session.use_trans_sid failed.

#0 /home/probusgi/public_html/ProbusLive/lib/Cake/Model/Datasource/CakeSession.php(619): CakeSession::_configureSession()

#1 /home/probusgi/public_html/ProbusLive/lib/Cake/Model/Datasource/CakeSession.php(632): CakeSession::_cookieName()

#2 /home/probusgi/public_html/ProbusLive/lib/Cake/Model/Datasource/CakeSession.php(248): CakeSession::_hasSession()

#3 /home/probusgi/public_html/ProbusLive/lib/Cake/Controller/Component/AuthComponent.php(670): CakeSession::check(‘Auth.User’)

#4 /home/probusgi/public_html/ProbusLive/lib/Cake/Controller/Component/AuthComponent.php(688): AuthComponent::user()

#5 /home/probusgi/public_html/ProbusLive/lib/Cake/Controller/Component/AuthComponent.php(301): AuthComponent->_getUser()

#6 /home/probusgi/public_html/ProbusLive/lib/Cake/Utility/ObjectCollection.php(129): AuthComponent->startup(Object(NotificationsController))

#7 /home/probusgi/public_html/ProbusLive/lib/Cake/Event/CakeEventManager.php(243): ObjectCollection->trigger(‘startup’)

#8 /home/probusgi/public_html/ProbusLive/lib/Cake/Controller/Controller.php(678): CakeEventManager->dispatch(Object(CakeEvent))

#9 /home/probusgi/public_html/ProbusLive/lib/Cake/Routing/Dispatcher.php(189): Controller->startupProcess()

#10 /home/probusgi/public_html/ProbusLive/lib/Cake/Routing/Dispatcher.php(167): Dispatcher->_invoke(Object(NotificationsController), Object(CakeRequest))

#11 /home/probusgi/public_html/ProbusLive/lib/Cake/Core/CakeObject.php(104): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse), Array)

#12 /home/probusgi/public_html/ProbusLive/app/Console/Command/NotificationsShell.php(7): CakeObject->requestAction(‘Notifications/n…’)

#13 /home/probusgi/public_html/ProbusLive/lib/Cake/Console/Shell.php(462): NotificationsShell->main()

#14 /home/probusgi/public_html/ProbusLive/lib/Cake/Console/ShellDispatcher.php(219): Shell->runCommand(NULL, Array)

#15 /home/probusgi/public_html/ProbusLive/lib/Cake/Console/ShellDispatcher.php(66): ShellDispatcher->dispatch()

#16 /home/probusgi/public_html/ProbusLive/lib/Cake/Console/cake.php(53): ShellDispatcher::run(Array)

#17 {main}

To try and find out where the header output occurs I tried inserting a “ini_set(‘session.use_cookies’,0)” statement at various points in the code indicated by the stack trace. This code from lib/Cake/Console/ShellDispatcher.php lines 64-67 seems significant.

public static function run($argv) {

$dispatcher = new ShellDispatcher($argv);

return $dispatcher->_stop($dispatcher->dispatch() === false ? 1 : 0);

}

If I insert the ini_set before the $dispatcher = new ShellDispatcher($argv); line the error is reported as above. However with the ini_set inserted after that line the error is reported at that line. Ie it’s suggesting the $dispatcher = new ShellDispatcher($argv); is causing headers to be sent to the console.

As I said it works on my wimdows setup but fails on cpanel.

It looks like a bug to be, but can anyone else throw any light on this please?

1 Like

I have the same issue now, but i’m using a virtual machine on vagrant. I can’t achieve to fix this!

Hi, if I ever did fix this I can’r remember what I did. I’m on version 3 now & everything works ok. sorry!

I’m working too cake 3 project, but I have and old project with this issue, only in virtual environment, under a VM. In real server this don’t happens. Ok, Bye