[3.10] Clear buffered output at all levels#30786
Conversation
|
The following code: // Clear buffered output at all levels
$callerFunction = static::getCallerFunctionName();
if ($callerFunction === false)
{
while (ob_get_level())
{
ob_end_clean();
}
}should be replaced with: // Clear buffered output at all levels
while (ob_get_level())
{
ob_end_clean();
} |
|
Ok will do when i'm back at my PC. |
|
Thanks @ethernidee this has just been commited to this PR. |
|
I have tested this item ✅ successfully on 0fda10a This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/30786. |
|
Tests are failing. |
/drone/src/tests/unit/suites/libraries/cms/error/JErrorPageTest.php:79
/drone/src/tests/unit/suites/libraries/cms/error/JErrorPageTest.php:123 Such things cannot be tested if buffer is cleared properly. The tests are invalid, imho. |
What is the point of clearing the buffer there anyway? |
|
Imagine you render Joomla module. First level of buffer capturing is on. Then in module template you write ob_start() for internal subwidget. If any error happens, Joomla will clear second level buffer and leave top of the default template rendered + will add error page html. This is totally wrong. All buffer levels should be cleared before rewriting the whole response, whether it's json or html response. I faced such situations on working sites and was really surprised. |
|
Makes sense, thanks |
|
The latest commits make sure the test suite passes as it starts the output buffer right after we cleaded it again. Else that thing will fail as the output puffes is clreandend but not restarted. |
|
Excellent solution! |
|
Thanks! |
| @@ -176,7 +182,7 @@ public static function render($error) | |||
| protected static function getCallerFunctionName() | |||
There was a problem hiding this comment.
@zero-24 I think this function can be removed now - it's not longer being called
There was a problem hiding this comment.
it could be used as its part of the API right? It can be removed with 4 i guess right?
There was a problem hiding this comment.
It's a protected function and introduced in 3.10 - its only been in alpha's so far?
There was a problem hiding this comment.
Ah ok will do a PR to get rid of it.
Pull Request for Issue #18088
Summary of Changes
Add back the check to clear the buffered output. cc @SharkyKZ
Testing Instructions
Enter non-existing url in browser to trigger 404 page.
Actual result BEFORE applying this Pull Request
Default template error page should be displayed, as usual.
Expected result AFTER applying this Pull Request
Default template error page should be displayed, as usual.
Documentation Changes Required
None