0

I'm building a simple Joomla 4 component, and I need to use a json view for some ajax requests. Just starting the testing process, and ran into an odd seemingly unrelated error message. I don't get this in HTML views, and the session storage is set to database.

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

My 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; ?>
3
  • I don't have a solution for you, however yesterday I was working with a Fetch in JS passing data to a Joomla 4 component and started receiving the same message. I found reloading the page was the only cure. In my case I am passing JSON but not using the &Format=JSON. I kind of agree with your suggestion that it is probably unrelated or at least not directly.
    – Irata
    Dec 1, 2022 at 2:07
  • Thanks @Irata, I tried loading the URL in an incognito browser, and the page is simply blank instead of the error display. Starting to wonder if this is a bug of some sort, but I'm not sure how to track it down.
    – James
    Dec 1, 2022 at 5:38
  • 1
    If you have debug enabled, it's a bug and you should report it to developers.
    – Sharky
    Dec 1, 2022 at 7:24

1 Answer 1

0

Posted this to the Joomla Issue Tracker. https://issues.joomla.org/tracker/joomla-cms/39341

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.