Welcome Guest, Not a member yet? Register   Sign In
Undefined method URI::siteUrl() after upgrading to 4.4.x
#1

(This post was last modified: 09-26-2023, 08:34 AM by DatDraggy.)

Hey there,
I've been busy upgrading my CI4 instance from 4.2.0 to 4.4.1. All went smooth until the step up to 4.4.0.

redirect()->route() returns $this->redirect(site_url()) 

Inside the site_url helper func, $currentURI is set from Services::request()->getUri();. However, getUri returns an instance of URI instead of the expected SiteURI.
$currentUri->siteUrl() is returned, but siteUrl is only present in the previously mentioned SiteURI.
 
I've researched this a bit and saw an issue regarding this exact thing, however it only concerned CLI and the fix in dev doesn't help me.

Am I missing something? Hope someone can help me out here.

I'm using nginx with php7.4-fpm
Reply
#2

Does this help:

https://codeigniter4.github.io/userguide...ri-changes
Reply
#3

(09-26-2023, 09:50 AM)JustJohnQ Wrote: Does this help:

https://codeigniter4.github.io/userguide...ri-changes

Thanks for the reply. Sadly doesn't help. I'm aware of the change, the issue is that the code in question is from CI4 itself, I can't modify it to use on prod. For some reason the site_url CI helper still uses URI, which doesn't have the ->siteUrl function, instead of SiteURI.
Reply
#4

Services::request()->getUri() should return SiteURI.
Find why it returns URI.
Did you customize CI4 or Config\Services?
Reply
#5

(This post was last modified: 09-27-2023, 03:07 AM by DatDraggy.)

(09-26-2023, 07:45 PM)kenjis Wrote: Services::request()->getUri() should return SiteURI.
Find why it returns URI.
Did you customize CI4 or Config\Services?

I'm using composer and upgraded the version step by step just like it says in the upgrading docs. app/Config/Services does have two custom functions, the issue persists after removing them though. get_class($currentUri) returns URI for me.
system/HTTP/Request.php typehint also says it only returns URI

Well okay, I seemed to have missed something. I had to update tests/_support/Config/Services.php. All working again. Thanks for the assistance
Reply




Theme © iAndrew 2016 - Forum software by © MyBB