Welcome Guest, Not a member yet? Register   Sign In
Updating from 4.2.1 to 4.4.6 session bug
#1

(This post was last modified: 03-12-2024, 04:57 AM by ramonpuig.)

Hello  I updated from 4.2.1 to 4.4.6 using composer. I followed general tips after i had issues with kint renderer and index.php. There are no particular instructions in here to upgrade from that version to the latest .

No i get these warnings and the error on $this->session = \Config\Services:Confusedession(); in my basecontroller.

Deprecated
: Creation of dynamic property Config\Exceptions::$logDeprecations is deprecated in /opt/lampp/htdocs/q/vendor/codeigniter4/framework/system/Debug/Exceptions.php on line 94

Deprecated: Creation of dynamic property Config\Exceptions::$deprecationLogLevel is deprecated in /opt/lampp/htdocs/q/vendor/codeigniter4/framework/system/Debug/Exceptions.php on line 95

ErrorException
Attempt to read property "driver" on null

PHP Code:
namespace App\Controllers;

use 
CodeIgniter\Controller;
use 
CodeIgniter\HTTP\CLIRequest;
use 
CodeIgniter\HTTP\IncomingRequest;
use 
CodeIgniter\HTTP\RequestInterface;
use 
CodeIgniter\HTTP\ResponseInterface;
use 
Psr\Log\LoggerInterface;

/**
 * Class BaseController
 *
 * BaseController provides a convenient place for loading components
 * and performing functions that are needed by all your controllers.
 * Extend this class in any new controllers:
 *    class Home extends BaseController
 *
 * For security be sure to declare any new methods as protected or private.
 */
abstract class BaseController extends Controller
{
    /**
    * Instance of the main Request object.
    *
    * @var CLIRequest|IncomingRequest
    */
    protected $request;

    /**
    * An array of helpers to be loaded automatically upon
    * class instantiation. These helpers will be available
    * to all other controllers that extend BaseController.
    *
    * @var array
    */
  
    
protected $includeTemplate true// Default value. To controll sidebar apparition depending on view
    protected $data=[];
    protected $language;
  
    
protected $sessionData;
    /**
    * Constructor.
    */

  
    
protected $helpers = ['utils''date''menu','menu_helper','html'];

    public function __construct()
    {
        
 
        
// Load helpers
        helper($this->helpers);
        
        
    
}


    public function initController(RequestInterface $requestResponseInterface $responseLoggerInterface $logger)
    {
        parent::initController($request$response$logger);

        
        $this
->session = \Config\Services::session();
        $this->language = \Config\Services::language();
        $this->language->setLocale($this->session->lang);
        // Preload any models, libraries, etc, here. 


The line :

PHP Code:
$this->session = \Config\Services::session(); 


is not working , the session is not initialized, and then i get the null value on all session operations. How is this happening? In version  4.2.1 it was not happening.

Any ideas? Did I miss something in the upgrade since I upgraded from a much older version of ci?

Cheers
Reply
Reply
#3

Quote:app/Config/Exceptions.php
    If you are using PHP 8.2, you need to add new properties $logDeprecations and $deprecationLogLevel
https://codeigniter4.github.io/CodeIgnit...ptions-php
Reply




Theme © iAndrew 2016 - Forum software by © MyBB