Welcome Guest, Not a member yet? Register   Sign In
Cannot access protected property CodeIgniter\HTTP\IncomingRequest::$uri
#1

Hello I followed the steps to upgrade from 4.4.8 to 4.5.0 ,

but i get this error

Cannot access protected property CodeIgniter\HTTP\IncomingRequest::$uri on line 75

PHP Code:
      // $this->language->setLocale($this->session->lang); 
69        // Preload any models, libraries, etc, here.    
70 
71        
// Determine whether to include the template or not
72            $excludedUrls = ['home','/','',NULL'about''login','register','users','/users/register','users/registerUser','registerUser','blog''contact'];
73 
74            
// Get the request URI segment 1
75            $requestUri $this->request->uri->getSegments();
76            $this->includeTemplate false;
77            foreach ($requestUri as $urisegment){
78 

Any ideas on the cause of the issue? thx
Reply
#2

(04-09-2024, 06:34 AM)ramonpuig Wrote: Hello I followed the steps to upgrade from 4.4.8 to 4.5.0 ,

but i get this error

Cannot access protected property CodeIgniter\HTTP\IncomingRequest::$uri on line 75

PHP Code:
      // $this->language->setLocale($this->session->lang); 
69        // Preload any models, libraries, etc, here.    
70 
71        
// Determine whether to include the template or not
72            $excludedUrls = ['home','/','',NULL'about''login','register','users','/users/register','users/registerUser','registerUser','blog''contact'];
73 
74            
// Get the request URI segment 1
75            $requestUri $this->request->uri->getSegments();
76            $this->includeTemplate false;
77            foreach ($requestUri as $urisegment){
78 

Any ideas on the cause of the issue? thx
This is how to getSegment in new upgrades, 

Code:
if (!function_exists('getSegment')) {
    function getSegment(int $number, string $default = '')
    {
        $request = \Config\Services::request();
        $uri = $request->getUri()->setSilent();
        return $uri->getSegment($number, $default);
    }
}
Reply
#3

If you are using CI 4.4, you can see the PHPDoc in the IncomingRequest class.
See @deprecated.

PHP Code:
    /**
    * The URI for this request.
    *
    * Note: This WILL NOT match the actual URL in the browser since for
    * everything this cares about (and the router, etc) is the portion
    * AFTER the baseURL. So, if hosted in a sub-folder this will
    * appear different than actual URI path. If you need that use getPath().
    *
    * @deprecated Will be protected. Use getUri() instead.
    *
    * @var URI
    */
    public $uri
Reply
#4

(04-09-2024, 06:34 AM)ramonpuig Wrote: Hello I followed the steps to upgrade from 4.4.8 to 4.5.0 ,

but i get this error

Cannot access protected property CodeIgniter\HTTP\IncomingRequest::$uri on line 75

PHP Code:
      // $this->language->setLocale($this->session->lang); 
69        // Preload any models, libraries, etc, here.    
70 
71        
// Determine whether to include the template or not
72            $excludedUrls = ['home','/','',NULL'about''login','register','users','/users/register','users/registerUser','registerUser','blog''contact'];
73 
74            
// Get the request URI segment 1
75            $requestUri $this->request->uri->getSegments();
76            $this->includeTemplate false;
77            foreach ($requestUri as $urisegment){
78 

Any ideas on the cause of the issue? thx
Change $this->request->uri and instead use:   $this->request->getUri()
Reply
#5

who was the idiot that did that....
it breaks an entire system. Why do standards keep changing so much to render an entire system needing an upgrade cause someone changes the syntax. 
ridiclous.
Reply
#6

(This post was last modified: 05-03-2024, 07:12 AM by Gary.)

In this business it helps if one is a masochist.  Smile

Consider minor syntactical changes that do result in breakages as hors d'oeuvres... it's the more subtle changes that don't cause outright breakages- which are typically harder to notice and often have an implication for site security- that are the real nut-shots (like the modifications to CI's routing).
Reply
#7

(04-25-2024, 02:10 PM)xsPurX Wrote: who was the idiot that did that....
it breaks an entire system. Why do standards keep changing so much to render an entire system needing an upgrade cause someone changes the syntax. 
ridiclous.
I would have not phrased it that way, but I agree with your sentiment. I chose this framework as a replacement for long term supported Laravel in an enterprise environment. In Codeigniter, only the most current version is patched. I chose Codeigniter for the increased speed, especially since I was not using many of Laravel’s included features.

Currently I have locked my version to < 4.5.0 and am trying to standardize on that for now. I am currently working on migrating an older 4.4.x project and then I know I have a 4.3.x one that needs to be moved to my new standard.

We can confidently use the latest PHP 8.3 version without fear of breakage, In my experience, the same cannot be said for Codeigniter.
Reply
#8

(05-03-2024, 03:39 AM)Bosborne Wrote:
(04-25-2024, 02:10 PM)xsPurX Wrote: who was the idiot that did that....
it breaks an entire system. Why do standards keep changing so much to render an entire system needing an upgrade cause someone changes the syntax. 
ridiclous.
I would have not phrased it that way, but I agree with your sentiment. I chose this framework as a replacement for long term supported Laravel in an enterprise environment. In Codeigniter, only the most current version is patched. I chose Codeigniter for the increased speed, especially since I was not using many of Laravel’s included features.

Currently I have locked my version to < 4.5.0 and am trying to standardize on that for now. I am currently working on migrating an older 4.4.x project and then I know I have a 4.3.x one that needs to be moved to my new standard.

We can confidently use the latest PHP 8.3 version without fear of breakage, In my experience, the same cannot be said for Codeigniter.

Yeah I was in a bit of a pissy mood, cause I was trying 4.5.1 and I decided to just keep 4.4.1 for now and lock down that version for now. I started my project back in Novemeber of last year, and it sat for a few months, and now a bunch of stuff changes again. It's frustrating, but I will build another application on 4.5.x most likely. I think its a better to approach an EOL for a software instead of updating it too much. So I will take that aproach instead of updating all the time.

I love codeigniter for the same reasons light weight and speed. Been using it since Version 1.8ish days. So yeah things change, but sometimes I wonder if some people get a kick out of breaking peoples code and making them work to get their applications updated lol.
Reply
#9

(05-03-2024, 07:17 AM)xsPurX Wrote:
(05-03-2024, 03:39 AM)Bosborne Wrote:
(04-25-2024, 02:10 PM)xsPurX Wrote: who was the idiot that did that....
it breaks an entire system. Why do standards keep changing so much to render an entire system needing an upgrade cause someone changes the syntax. 
ridiclous.
I would have not phrased it that way, but I agree with your sentiment. I chose this framework as a replacement for long term supported Laravel in an enterprise environment. In Codeigniter, only the most current version is patched. I chose Codeigniter for the increased speed, especially since I was not using many of Laravel’s included features.

Currently I have locked my version to < 4.5.0 and am trying to standardize on that for now. I am currently working on migrating an older 4.4.x project and then I know I have a 4.3.x one that needs to be moved to my new standard.

We can confidently use the latest PHP 8.3 version without fear of breakage, In my experience, the same cannot be said for Codeigniter.

Yeah I was in a bit of a pissy mood, cause I was trying 4.5.1 and I decided to just keep 4.4.1 for now and lock down that version for now. I started my project back in Novemeber of last year, and it sat for a few months, and now a bunch of stuff changes again. It's frustrating, but I will build another application on 4.5.x most likely. I think its a better to approach an EOL for a software instead of updating it too much. So I will take that aproach instead of updating all the time.

I love codeigniter for the same reasons light weight and speed. Been using it since Version 1.8ish days. So yeah things change, but sometimes I wonder if some people get a kick out of breaking peoples code and making them work to get their applications updated lol.

You can probably use the latest 4.4 (4.4.8?) That is what I chose, at least until I get confidence in 4.5 It was patches 2 weeks after release.
Reply
#10

Do you use automatic routing? Or do you create all routes manually?
Without autorouting, you can change your filter to match the route names. This is a more reliable option. It does not depend on URLs. 
Try to implement this and you will be surprised how much less you need to edit new CI4 changes.
See https://codeigniter4.github.io/userguide...med-routes
Example code: 

PHP Code:
// Routes with names "as": users, about,...

$router    Services::router();
$routeName $router->getMatchedRouteOptions()['as'] ?? '';

if (
in_array($routeName, ['users''about'], true)) {
        // any actions

Simple CI 4 project for beginners codeigniter-expenses
Reply




Theme © iAndrew 2016 - Forum software by © MyBB