Issue Bug Closed

#88015Can't edit TCA records with language set to All languages(sys_language_uid = -1)

Ricky Mathew 03/27/19, 07:23 updated 08/22/19, 18:34

Description

I have lot of TCA records with language set to All languages (sys_language_uid = -1) . But i cant edit the TCA records since it throws the following error:


(1/1) #1522960188 InvalidArgumentException
Language -1 does not exist on site example.

in typo3/sysext/core/Classes/Site/Entity/Site.php line 237

        throw new \InvalidArgumentException(
            'Language ' . $languageId . ' does not exist on site ' . $this->identifier . '.',
            1522960188
        );
    }

The error throws obviously as -1 is not there in the corresponding site configuration.So i added a patch in typo3/sysext/core/Classes/Site/Entity/Site.php as follows and it works and not breaking anything else.

    public function getLanguageById(int $languageId): SiteLanguage
    {
        if (isset($this->languages[$languageId])) {
            return $this->languages[$languageId];
        }
        /**patch to fix editing of TCA records set with All languages(sys_language_uid = -1)**/
        elseif ($languageId == -1) {
            return $this->languages[0];
        }
        throw new \InvalidArgumentException(
            'Language ' . $languageId . ' does not exist on site ' . $this->identifier . '.',
            1522960188
        );
    }

If this solution feels sensible can anyone please push it to the gerrit review.

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.