Support

Akeeba Ticket System

#27291 PHP 7.x issue with customfields

Posted in ‘Akeeba Ticket System for Joomla! 4 & 5’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Environment Information

Joomla! version
n/a
PHP version
n/a
Akeeba Ticket System version
n/a

Latest post by weeblr on Wednesday, 08 March 2017 09:08 CST

weeblr
 Hi

Stumbled upon an issue in ATS 2.2.3, which doesn't appear in the changelog of your current dev version.

I added a text custom field to tickets. That went well, and the field is actually displayed on titcket on front end as expected. However trying to edit that custom field in the backednd result in a PHP error, under PHP 7.1.0 (didn't try, bt pretty sure the same would happen with 7.0.x)

The error is:
[] operator not supported for strings


After some debugging, I found that this is caused by an incorrect, or maybe missing initilization of the value property of the CustomfieldCats custom field class:
class CustomfieldCats extends GenericList
{
    protected function getInput()
    {
        /** @var \Akeeba\TicketSystem\Admin\Model\CustomFields $item */
        $item = $this->form->getModel();

        // Initialize to array, avoid [] operator not supported for strings error 
        $this->value = empty($this->value) ? array() : $this->value();
        //
	    
        foreach($item->cats as $cat)
        {
            $this->value[] = $cat->id;
        }

        return parent::getInput();
    }

    protected function getOptions()
    {
        $options = Select::getCategoriesOptions();

        return $options;
    }
}


Initiliazing the $this->value is enough. It seems to be initialized as an empty string, which causes the error.

I didn't dig further to find how "value" was initialized, nor to other CustomFields, which may also have the same problem.

Rgds

tampe125
Akeeba Staff
Hello Yannick,

thank you very much for the report.
It is indeed a new change in PHP 7.1. Your change seems good, I just updated our code, you'll find the fix in the next version.

Davide Tampellini

Developer and Support Staff

🇮🇹Italian: native 🇬🇧English: good • 🕐 My time zone is Europe / Rome (UTC +1)
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

weeblr
Hi Davide

all good then!

Rgds

Support Information

Working hours: We are open Monday to Friday, 9am to 7pm Cyprus timezone (EET / EEST). Support is provided by the same developers writing the software, all of which live in Europe. You can still file tickets outside of our working hours, but we cannot respond to them until we're back at the office.

Support policy: We would like to kindly inform you that when using our support you have already agreed to the Support Policy which is part of our Terms of Service. Thank you for your understanding and for helping us help you!