Description
PHP Version
8.3
CodeIgniter4 Version
4.6
CodeIgniter4 Installation Method
Git
Which operating systems have you tested for this bug?
Linux
Which server did you use?
cli-server (PHP built-in webserver)
What happened?
At the moment, Superglobals looks like a stub. There are no necessary actions:
-
There is no getting all the values as an array. For example, to replace it in the
Router
:$this->globals['server'] = $_SERVER;
CodeIgniter4/system/Commands/Utilities/Routes.php
Lines 89 to 94 in e475fd8
-
The server() method can return not only a
string
, but alsostring|int|float|array
. Array for argv, float for REQUEST_TIME
CodeIgniter4/system/Superglobals.php
Line 33 in e475fd8
-
Keys cannot be deleted as
unset($_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI'])
-
Something important is in the process..
To upgrade to Superglobals, you need to check the all code. Because in many places, $_SERVER is overwritten. I'll try to get started.
I could send a PR, but I need to understand what to do. Is the function that I described enough for this?
I'm really sorry, this is more of a feature request. But I have problems accessing the forum.
Activity
mergeable commentedon Jan 9, 2025
neznaika0 commentedon Jan 9, 2025
@paulbalandan @samsonasik Has a policeman appeared? 😄
samsonasik commentedon Jan 9, 2025
@paulbalandan it seems due to mergeable PR:
@neznaika0 let's reopen
michalsn commentedon Jan 10, 2025
From what I see, the
Superglobals
class was created with the intention to handle all superglobals, so I guess the idea of using it is fine. However, currently, it's used only with theSiteURIFactory
class and is handling only these superglobals used for URL manipulation.We can ask @kenjis if there was a reason we didn't pursue this further. He is definitely the best-oriented person in this area (as the author) so his opinion can save us some time.
michalsn commentedon Jan 10, 2025
@neznaika0 What exactly are the problems with accessing the forum?
neznaika0 commentedon Jan 10, 2025
@kenjis has been very busy for a long time. We could first describe the interface and then implement the methods. It seems to me that it would be possible to extend ArrayObject or Iterable... The task is to hide the array in an object
I opened a topic in the Lounge on the forum. Cloudflare Encrypted Client Hello (ECH) was banned in my country. I'm 50/50% open to a forum or a long wait. Sometimes it opens normally
neznaika0 commentedon Jan 22, 2025
@kenjis can I say a few words about the development of the service?
I see it differently.
Add a new
Parameters
class to replace the array with theget(), set(), has(), count()
and other methods. It can be extended toInputParameters
andServerParameters
. Because they have restrictions on the scalar type of the value.Replace
$_SERVER, $_POST, $_GET, $_REQUEST
(may be$_COOKIE
) with theParameters
object.Extends
Superglobals
. So that the parameters are saved during the request. Most likely as a static object (Services
function)Do I still need to think about rewriting $_***. Only in
Request
or otherwise?kenjis commentedon Jan 22, 2025
Yes, it was created with the intention to handle all superglobals (
$_***
).So we should use it in all places.
Now it's used only with the SiteURIFactory class, because replacing all the code base was too big task.
neznaika0 commentedon Jan 22, 2025
If there's time, I'll try to show you a draft with an update. This substitution will improve testability. But there are doubts about
$_ENV
.I've studied Symfony a bit, I think it will be possible to implement it in CI.
[-]Bug: Supeglobals does not fully support actions[/-][+]Bug: Superglobals does not fully support actions[/+]Superglobals
service #9482