? Pending

User tests: Successful: Unsuccessful:

avatar zero-24
zero-24
27 Sep 2020

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

avatar zero-24 zero-24 - open - 27 Sep 2020
avatar zero-24 zero-24 - change - 27 Sep 2020
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 27 Sep 2020
Category Libraries
avatar ethernidee
ethernidee - comment - 27 Sep 2020

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();
}
avatar zero-24
zero-24 - comment - 27 Sep 2020

Ok will do when i'm back at my PC.

avatar zero-24 zero-24 - change - 27 Sep 2020
Labels Added: ?
avatar zero-24
zero-24 - comment - 27 Sep 2020

Thanks @ethernidee this has just been commited to this PR.

avatar particthistle particthistle - test_item - 28 Sep 2020 - Tested successfully
avatar particthistle
particthistle - comment - 28 Sep 2020

I have tested this item successfully on 0fda10a

Default template error page should be displayed, as expected.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/30786.

avatar SharkyKZ
SharkyKZ - comment - 28 Sep 2020

Tests are failing.

avatar ethernidee
ethernidee - comment - 28 Sep 2020
  1. JErrorPageTest::testEnsureTheErrorPageIsCorrectlyRendered
    Failed asserting that false matches expected '<title>500 - Testing JErrorPage::render() with RuntimeException</title>Testing JErrorPage::render() with RuntimeException'.

/drone/src/tests/unit/suites/libraries/cms/error/JErrorPageTest.php:79

  1. JErrorPageTest::testEnsureTheErrorPageIsCorrectlyRenderedWithThrowables
    Failed asserting that false matches expected '<title>500 - Testing JErrorPage::render() with PHP 7 Error</title>Testing JErrorPage::render() with PHP 7 Error'.

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

avatar zero-24
zero-24 - comment - 29 Sep 2020

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?

avatar ethernidee
ethernidee - comment - 29 Sep 2020

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.

avatar zero-24
zero-24 - comment - 29 Sep 2020

Makes sense, thanks

avatar zero-24
zero-24 - comment - 3 Oct 2020

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.

avatar ethernidee
ethernidee - comment - 3 Oct 2020

Excellent solution!

avatar richard67 richard67 - close - 19 Jan 2021
avatar richard67 richard67 - merge - 19 Jan 2021
avatar richard67 richard67 - change - 19 Jan 2021
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2021-01-19 13:52:52
Closed_By richard67
avatar richard67
richard67 - comment - 19 Jan 2021

Thanks!

Add a Comment

Login with GitHub to post a comment