No Code Attached Yet Information Required
avatar JamesShaver
JamesShaver
1 Dec 2022

Steps to reproduce the issue

Build a component view for json formatted output.

URL:

http://localhost/joomla/index.php?option=com_testcomponent&view=json&format=json

site\src\View\Json\JsonView.php:
<?php

namespace Joomla\Component\Testcomponent\Site\View\Json;

use Joomla\CMS\MVC\View\JsonView as BaseJsonView;

class JsonView extends BaseJsonView
{
    public $json;
    
    public function display($tpl = null)
    {
        $array = [
            'key1' => 'value1',
            'key2' => 'value2',
            'key3' => 'value3',
            'key4' => 'value4'
        ];
        $this->json = json_encode($array);
        
        parent::display($tpl);
    }
}
site\tmpl\json\json.php:
<?= $this->json; ?>

Expected result

{"key1":"value1","key2":"value2","key3":"value3","key4":"value4"}

Actual result

<br />
<b>Warning</b>:  session_write_close(): Failed to write session data using user defined save handler. (session.save_path: \Users\username\OneDrive\Documents\Development\xampp\tmp) in <b>C:\Users\username\OneDrive\Documents\Development\xampp\htdocs\joomla\libraries\vendor\joomla\session\src\Storage\NativeStorage.php</b> on line <b>114</b><br />

System information (as much as possible)

MS Windows 11
XAMPP for Windows 8.1.12
Apache/2.4.54 (Win64)
PHP Version 8.1.12

Additional comments

Debug mode is turned on, but nothing populates in everything.php

avatar JamesShaver JamesShaver - open - 1 Dec 2022
avatar JamesShaver JamesShaver - change - 1 Dec 2022
Labels Removed: ?
avatar joomla-cms-bot joomla-cms-bot - change - 1 Dec 2022
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 1 Dec 2022
avatar Irata
Irata - comment - 1 Dec 2022

I am seeing the same messages, intermittently, about failing to write the session when invoking a controller via JS that passes to and is returned JSON.

url = 'index.php?option=com_mycomponent&task=mycontroller.incoming&format=json';

my controller does almost nothing

public function incoming()
	{
		$barney = $this->app->input->post->get('payload', '', 'array');
		$response = new JsonResponse($barney);
		echo $response;
	}

Reloading the page resolves the issue for awhile but its return is seemingly random.

I don't have anymore diagnostics than already supplied at this stage.

PHP Version 8.0.23
Web Server Apache/2.4.54 (Win64) OpenSSL/1.1.1q PHP/8.0.23
WebServer to PHP Interface apache2handler
Joomla! Version Joomla! 4.2.5 Stable [ Uaminifu ] 8-November-2022 15:00 GMT

Running on a local LAMP stack.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/39341.
avatar SharkyKZ
SharkyKZ - comment - 2 Dec 2022

This is coming from recent changes in debug plugin. When Track Request History option is disabled, an unlimited number of request data is stored in the session until a HTML page is opened.

avatar JamesShaver
JamesShaver - comment - 2 Dec 2022

Confirmed, enabling Track Request History removes the error message.

avatar richard67
richard67 - comment - 2 Dec 2022

@SharkyKZ So it’s a bug, right?

avatar MacJoom
MacJoom - comment - 9 Dec 2022

Steps to reproduce the issue

Build a component view for json formatted output.

URL:

http://localhost/joomla/index.php?option=com_testcomponent&view=json&format=json

site\src\View\Json\JsonView.php:
<?php

namespace Joomla\Component\Testcomponent\Site\View\Json;

use Joomla\CMS\MVC\View\JsonView as BaseJsonView;

class JsonView extends BaseJsonView
{
    public $json;
    
    public function display($tpl = null)
    {
        $array = [
            'key1' => 'value1',
            'key2' => 'value2',
            'key3' => 'value3',
            'key4' => 'value4'
        ];
        $this->json = json_encode($array);
        
        parent::display($tpl);
    }
}
site\tmpl\json\json.php:
<?= $this->json; ?>

Expected result

{"key1":"value1","key2":"value2","key3":"value3","key4":"value4"}

Actual result

<br />
<b>Warning</b>:  session_write_close(): Failed to write session data using user defined save handler. (session.save_path: \Users\username\OneDrive\Documents\Development\xampp\tmp) in <b>C:\Users\username\OneDrive\Documents\Development\xampp\htdocs\joomla\libraries\vendor\joomla\session\src\Storage\NativeStorage.php</b> on line <b>114</b><br />

System information (as much as possible)

MS Windows 11 XAMPP for Windows 8.1.12 Apache/2.4.54 (Win64) PHP Version 8.1.12

Additional comments

Debug mode is turned on, but nothing populates in everything.php

I cannot reproduce the issue with your code since JsonView doesnt apply any template code. So the output is always empty... tmpl\json\json.php is never called. parent::display just puts this->_output into the documents buffer. $this->json is not used.
I can think of a problem where the session data is growing too much, but cannot reproduce the issue right now.
Please post the complete code with this issue - Thank you

avatar richard67 richard67 - change - 9 Dec 2022
Labels Added: Information Required
avatar richard67 richard67 - labeled - 9 Dec 2022
avatar richard67
richard67 - comment - 12 Dec 2022

@MacJoom Which PHP version have you used when trying to reproduce the issue? Was it 7.4? Possibly the issue happens only with PHP 8.x.

avatar richard67
richard67 - comment - 12 Dec 2022

I have found another thing which happens with PHP 8 which happens when the "Track Request History" option in the "Debug" system plugin is disabled and disappears when that option is enabled. See #39403 . It seems they have the same root cause, but I wanted the symptoms to be documented and so created that other issue.

avatar richard67 richard67 - close - 30 Dec 2022
avatar richard67
richard67 - comment - 30 Dec 2022

Closing as having a pull request. Please test #39526 . Thanks in advance.

avatar richard67 richard67 - change - 30 Dec 2022
Status New Closed
Closed_Date 0000-00-00 00:00:00 2022-12-30 09:55:31
Closed_By richard67

Add a Comment

Login with GitHub to post a comment