![]() |
Upgraded my site from 4.3.8 to 4.5.5 this morning. I have gone through all the changes version by version and have the site basically running again. One issue that has me completely stopped is the behavior of site_url(). I know there were breaking changes around 4.4, but I can't for the life of me see how they apply in this case. What I have...
In my .env file: PHP Code: app.baseURL = 'https://domain.com/' In my view file: PHP Code: <a class="nav-link" href="<?= site_url() ?>" target="_blank"> In 4.3.8 (and before) this returned: PHP Code: <a class="nav-link" href="https://domain.com" target="_blank"> In 4.5.5 it is returning: PHP Code: <a class="nav-link" href="" target="_blank"> If I put a value in: PHP Code: app.indexPage = 'index' I get (in 4.5.5): PHP Code: <a class="nav-link" href="https://index/index" target="_blank"> PHP Code: <a class="nav-link" href="<?= site_url('news/local/123'); ?>" target="_blank"> I get: PHP Code: <a class="nav-link" href="https://news/news/local/123" target="_blank"> Is there a setting somewhere I missed during the upgrades? Am I missing something obvious in the docs? Help!
there are tests in the framework. they pass site_url() checks. have you updated all the files in app? Maybe you replaced the service for URI?
(11-23-2024, 08:50 PM)ozornick Wrote: there are tests in the framework. they pass site_url() checks. have you updated all the files in app? Maybe you replaced the service for URI? Sorry, I am not understanding your answer or what I need to check exactly. Could you please expand on that with more detail?
Hmmm... just realized that only on the "home page" is "site_url" returning nothing. On sub pages, site_url is properly returning "domain.com"...
Not sure if it is related, but also noticed that the CI Toolbar is not loading on the home page, but is on the sub pages.
Digging some more, the problem seems to be tied to this error in the logs:
PHP Code: WARNING - 2024-11-25 11:27:04 --> [DEPRECATED] Automatic conversion of false to array is deprecated in SYSTEMPATH/HTTP/SiteURI.php on line 120. Unless I comment out the HTTPException, this is what error comes up when I try to use site_url() on my home page (https://domain.com/auction) PHP Code: CRITICAL - 2024-11-25 11:28:21 --> CodeIgniter\HTTP\Exceptions\HTTPException: Unable to parse URI: "https://" Here's the relevant code from SiteURI.php PHP Code: // Fix the current URI In an effort to get past this and get the app back up and running, I created a simple replacement helper that doesn't have all the bells and whistles of the original, at least gets me running again for now: NEVERMIND, THIS DIDN'T WORK AS THE TOOLBAR WAS STILL BROKEN. PHP Code: if (! function_exists('p42_site_url')) {
Open issue on github?
In the end I setup a new site with a clean CI install. Ran a diff on all Config, etc files and made any tweaks (nothing related found). Then I started moving my Controllers, Views, etc over in groups until I "broke" the new site. Turned out that the issue was being caused by the auth module CI4-Auth ( https://github.com/glewe/ci4-auth ). Once I moved all my files and disabled all the stuff related to CI-Auth, the problem went away.
There is a newish release of CI4-Auth that requires CI 4.5. Installed that and took the time to apply my customizations. BAM! All good now. App is finally back to working as it was before the upgrade of CI. Thanks for your suggestions. |
Welcome Guest, Not a member yet? Register Sign In |