CodeIgniter Forums
Undefined method URI::siteUrl() after upgrading to 4.4.x - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Undefined method URI::siteUrl() after upgrading to 4.4.x (/showthread.php?tid=88554)



Undefined method URI::siteUrl() after upgrading to 4.4.x - DatDraggy - 09-26-2023

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


RE: Undefined method URI::siteUrl() after upgrading to 4.4.x - JustJohnQ - 09-26-2023

Does this help:

https://codeigniter4.github.io/userguide/changelogs/v4.4.0.html#site-uri-changes


RE: Undefined method URI::siteUrl() after upgrading to 4.4.x - DatDraggy - 09-26-2023

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

https://codeigniter4.github.io/userguide/changelogs/v4.4.0.html#site-uri-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.


RE: Undefined method URI::siteUrl() after upgrading to 4.4.x - kenjis - 09-26-2023

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


RE: Undefined method URI::siteUrl() after upgrading to 4.4.x - DatDraggy - 09-27-2023

(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