Closed pocketarc closed 1 year ago
This patch has already been applied to the develop
branch which is currently version 3.2.0-dev and includes many other PHP 8.1 patches.
@daveherman71 I am able to reproduce this in 3.2.0-dev, which is the version I'm running. I can provide a test example if necessary (an empty function in a controller -should- do it).
If you have a look at the code in the repository you will see that the patch has already been applied.
// Set the output data
if ($output === NULL)
{
$output =& $this->final_output;
}
I think there might be some confusion. The code I have in my comment isn't my patch. It's code that I know was already there, it's part of the discussion.
You can click the Files changed
tab to see my patch.
Please provide an example, I tried your suggestion and the output is an empty string (not NULL) and no error was thrown.
My code:
class Test extends CI_Controller {
public function nothing()
{
}
}
The results of a cURL request are as follows:
C:\>curl -i http://localhost:8000/test/nothing
HTTP/1.1 200 OK
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Content-Type: text/html; charset=UTF-8
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Server: localhost
Set-Cookie: ci_session=s4djnf0a29p1pu93l9i49ijpvdfm07ch; path=/; secure; HttpOnly; SameSite=Lax
Date: Thu, 08 Jun 2023 12:01:25 GMT
Content-Length: 0
This is reproducible by calling $this->set_output(null)
, which is allowed by CI, and in my mind makes this an issue, but it can easily be resolved by telling the end user to just change their code, so I'm closing the PR.
At the moment, if a page doesn't use CI for output (e.g. sending a file's contents), an E_DEPRECATED will be triggered because $output is null:
This is a quick fix for that.
Note: The code seems to override the original $output with $this->final_output, which initially is a string, but isn't when it actually gets to that point. I didn't investigate that further, as there was no need, but it was surprising.