Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PaletteManipulator causes error, if palette happens to have 'invalid' data #421

Closed
fritzmg opened this issue Apr 3, 2019 · 1 comment
Closed
Assignees
Labels
Milestone

Comments

@fritzmg
Copy link
Contributor

fritzmg commented Apr 3, 2019

Affected version(s)
4.7.2

Description
If a palette contains a trailing ; for example and you try to apply anything on that palette with the PaletteManipulator the following error will occur:

TypeError:
preg_match() expects parameter 2 to be string, null given

  at vendor/contao/contao/core-bundle/src/DataContainer/PaletteManipulator.php:199
  at preg_match('#\\{(.+?)(:hide)?\\}#', null, array('{invisible_legend:hide}', 'invisible_legend', ':hide'))
     (vendor/contao/contao/core-bundle/src/DataContainer/PaletteManipulator.php:199)
  at Contao\CoreBundle\DataContainer\PaletteManipulator->explode('{type_legend},type,headline;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID;{invisible_legend:hide},invisible,start,stop;')
     (vendor/contao/contao/core-bundle/src/DataContainer/PaletteManipulator.php:139)
  at Contao\CoreBundle\DataContainer\PaletteManipulator->applyToString('{type_legend},type,headline;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID;{invisible_legend:hide},invisible,start,stop;')
     (vendor/contao/contao/core-bundle/src/DataContainer/PaletteManipulator.php:119)
  at Contao\CoreBundle\DataContainer\PaletteManipulator->applyToPalette('headline', 'tl_content')
     (app/Resources/contao/dca/tl_content.php:8)
  at include('…/app/Resources/contao/dca/tl_content.php')
     (vendor/contao/contao/core-bundle/src/Resources/contao/library/Contao/DcaLoader.php:94)
  at Contao\DcaLoader->load(false)
     (vendor/contao/contao/core-bundle/src/Resources/contao/library/Contao/Controller.php:1279)
  at Contao\Controller::loadDataContainer('tl_content')
     (vendor/contao/contao/core-bundle/src/Resources/contao/drivers/DC_Table.php:3391)
  at Contao\DC_Table->reviseTable()
     (vendor/contao/contao/core-bundle/src/Resources/contao/drivers/DC_Table.php:319)
  at Contao\DC_Table->showAll()
     (vendor/contao/contao/core-bundle/src/Resources/contao/classes/Backend.php:616)
  at Contao\Backend->getBackendModule('article', null)
     (vendor/contao/contao/core-bundle/src/Resources/contao/controllers/BackendMain.php:169)
  at Contao\BackendMain->run()
     (vendor/contao/contao/core-bundle/src/Controller/BackendController.php:48)
  at Contao\CoreBundle\Controller\BackendController->mainAction()
     (vendor/symfony/http-kernel/HttpKernel.php:150)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
     (vendor/symfony/http-kernel/HttpKernel.php:67)
  at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
     (vendor/symfony/http-kernel/Kernel.php:198)
  at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
     (web/app_dev.php:83)

This is a problem, because some extensions aren't very "clean" when it comes to palette manipulation. A trailing ; that was added by one extension should not break the usage of the PaletteManipulator of any following extension.

How to reproduce
Create the file app/Resources/contao/dca/tl_content.php with the following content:

<?php

$GLOBALS['TL_DCA']['tl_content']['palettes']['headline'] .= ';';

\Contao\CoreBundle\DataContainer\PaletteManipulator::create()
    ->addLegend('test_legend', 'expert_legend')
    ->addField('testField', 'test_legend')
    ->applyToPalette('headline', 'tl_content');

Then log into the back end and go to Content » Articles. The aforementioned error will occur.

@leofeyer
Copy link
Member

leofeyer commented Apr 8, 2019

Fixed in 02fa1e1.

@leofeyer leofeyer closed this as completed Apr 8, 2019
@leofeyer leofeyer modified the milestones: 4.7.3, 4.7 May 14, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants