Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Supeglobals does not fully support actions #9392

Open
neznaika0 opened this issue Jan 9, 2025 · 6 comments
Open

Bug: Supeglobals does not fully support actions #9392

neznaika0 opened this issue Jan 9, 2025 · 6 comments

Comments

@neznaika0
Copy link
Contributor

neznaika0 commented Jan 9, 2025

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:

  1. There is no getting all the values as an array. For example, to replace it in the Router: $this->globals['server'] = $_SERVER;

    if ($host !== null) {
    $request = service('request');
    $_SERVER = $request->getServer();
    $_SERVER['HTTP_HOST'] = $host;
    $request->setGlobal('server', $_SERVER);
    }

  2. The server() method can return not only a string, but also string|int|float|array. Array for argv, float for REQUEST_TIME

    public function server(string $key): ?string

  3. Keys cannot be deleted as unset($_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI'])

    unset($_ENV['CI_ENVIRONMENT'], $_SERVER['CI_ENVIRONMENT']);

  4. 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.

@neznaika0 neznaika0 added the bug Verified issues on the current code behavior or pull requests that will fix them label Jan 9, 2025
@mergeable mergeable bot closed this as completed Jan 9, 2025

This comment was marked as off-topic.

@neznaika0
Copy link
Contributor Author

neznaika0 commented Jan 9, 2025

@paulbalandan @samsonasik Has a policeman appeared? 😄

@samsonasik
Copy link
Member

@paulbalandan it seems due to mergeable PR:

@neznaika0 let's reopen

@samsonasik samsonasik reopened this Jan 9, 2025
@michalsn
Copy link
Member

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 the SiteURIFactory 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
Copy link
Member

@neznaika0 What exactly are the problems with accessing the forum?

@neznaika0
Copy link
Contributor Author

@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

@michalsn michalsn removed the bug Verified issues on the current code behavior or pull requests that will fix them label Jan 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants