codefog / contao-events_subscriptions

Contao extension that allows members of your website to subscribe to the events
MIT License
10 stars 5 forks source link

Error after cache warmup: [] operator not supported for strings #107

Open rustykowski opened 1 month ago

rustykowski commented 1 month ago

Contao 4.13.49 contao-events_subscriptions 2.16.4

Exception in file var/cache/prod/contao/dca/tl_member.php on line 224[] operator not supported for strings

The content of line 224 is: $GLOBALS['TL_DCA']['tl_member']['palettes']['__selector__'][] = 'subscription_enableLimit';

stacktrace:

#0 vendor/contao/core-bundle/src/Resources/contao/library/Contao/DcaLoader.php(105): include()
#1 vendor/contao/core-bundle/src/Resources/contao/library/Contao/DcaLoader.php(75): Contao\DcaLoader->loadDcaFiles(false)
#2 vendor/contao/core-bundle/src/Resources/contao/library/Contao/Controller.php(1454): Contao\DcaLoader->load()
#3 vendor/contao/core-bundle/src/Migration/Version413/BooleanFieldsMigration.php(89): Contao\Controller::loadDataContainer('tl_member')
#4 vendor/contao/core-bundle/src/Migration/Version413/BooleanFieldsMigration.php(44): Contao\CoreBundle\Migration\Version413\BooleanFieldsMigration->getTargets()
#5 vendor/contao/core-bundle/src/Migration/MigrationCollection.php(47): Contao\CoreBundle\Migration\Version413\BooleanFieldsMigration->shouldRun()
#6 vendor/contao/core-bundle/src/Migration/MigrationCollection.php(58): Contao\CoreBundle\Migration\MigrationCollection->getPending()
#7 vendor/contao/core-bundle/src/Command/MigrateCommand.php(262): Contao\CoreBundle\Migration\MigrationCollection->getPendingNames()
#8 vendor/contao/core-bundle/src/Command/MigrateCommand.php(209): Contao\CoreBundle\Command\MigrateCommand->executeMigrations(true, true, NULL)
#9 vendor/contao/core-bundle/src/Command/MigrateCommand.php(109): Contao\CoreBundle\Command\MigrateCommand->executeCommand(Object(Symfony\Component\Console\Input\ArgvInput))
#10 vendor/symfony/console/Command/Command.php(298): Contao\CoreBundle\Command\MigrateCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 vendor/symfony/console/Application.php(1058): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 vendor/symfony/framework-bundle/Console/Application.php(96): Symfony\Component\Console\Application->doRunCommand(Object(Contao\CoreBundle\Command\MigrateCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 vendor/symfony/console/Application.php(301): Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand(Object(Contao\CoreBundle\Command\MigrateCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 vendor/symfony/framework-bundle/Console/Application.php(82): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 vendor/symfony/console/Application.php(171): Symfony\Bundle\FrameworkBundle\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 vendor/contao/manager-bundle/bin/contao-console(38): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput))
#17 {main}
qzminski commented 1 month ago

Have you got any other extensions installed? The __selector__ should never be a string.

rustykowski commented 1 month ago

yes, a few:

        "bugbuster/contao-visitors-bundle": "^1.8",
        "codefog/contao-cookiebar": "^2.5",
        "codefog/contao-events_subscriptions": "^2.16.3",
        "contao/calendar-bundle": "4.13.*",
        "contao/conflicts": "*@dev",
        "contao/manager-bundle": "4.13.*",
        "contao/news-bundle": "4.13.*",
        "contao/newsletter-bundle": "4.13.*",
        "dklemmt/contao_dk_mmenu": "^3.2",
        "do-while/contao-backupdb-bundle": "^1.5",
        "inspiredminds/contao-glightbox": "^1.0",
        "jrgregory/m17-sticky-backend-footer": "^2.0",
        "madeyourday/contao-rocksolid-custom-elements": "^2.4",
        "terminal42/contao-easy_themes": "^3.0",
        "terminal42/contao-pageimage": "^4.1",
        "terminal42/notification_center": "^1.6",
        "thescrat/contao-loginlink": "^1.0"
rustykowski commented 1 month ago

the last updated first-level dependency was thescrat/contao-loginlink

image
qzminski commented 1 month ago

Honestly I don't think error is coming from my extension. There must be a different extension that modifies the __selector__ to be a string, whereas it must be an array. Is there any custom code in your app?

thescrat commented 1 month ago

Honestly I don't think error is coming from my extension. There must be a different extension that modifies the __selector__ to be a string, whereas it must be an array. Is there any custom code in your app?

I think the error is caused by your extension. The error message says that the selector is wrong. The selector must be an array and the index should be a string.

So you can fix the error by doing this: $GLOBALS['TL_DCA']['tl_member']['palettes']['__selector__']['subscription_enableLimit'] = 'subscription_enableLimit';

aschempp commented 1 month ago

The selector must be an array and the index should be a string.

The selector already is an array: https://github.com/codefog/contao-events_subscriptions/blob/master/dca/tl_member.php#L26

The key is not relevant, as you can see in any Contao core file: https://github.com/contao/contao/blob/5.x/core-bundle/contao/dca/tl_member.php#L85

qzminski commented 1 month ago

To dump what's causing an error, you could try to dump the selector in file var/cache/prod/contao/dca/tl_member.php on line 223 (!):

dd($GLOBALS['TL_DCA']['tl_member']['palettes']['__selector__']);
rustykowski commented 1 month ago

I've discovered the following warning:

Warning: Array to string conversion {"exception":"[object] (ErrorException(code: 0): Warning: Array to string conversion at /www/htdocs/.../var/cache/prod/contao/dca/tl_member.php:152)"} []

The relevant line (2nd line) is:

namespace {
$GLOBALS['TL_DCA']['tl_member']['palettes'] = \str_replace('{account_legend}', '{loginLink_legend},loginLink,loginLinkGen;{account_legend}', $GLOBALS['TL_DCA']['tl_member']['palettes']);
\array_insert($GLOBALS['TL_DCA']['tl_member']['fields'], \count($GLOBALS['TL_DCA']['tl_member']['fields']), array('loginLink' => array('label' => &$GLOBALS['TL_LANG']['tl_member']['loginLink'], 'inputType' => 'text', 'eval' => array('minlength' => 10, 'unique' => \true, 'tl_class' => 'w50'), 'sql' => "varchar(255) NOT NULL default ''"), 'loginLinkGen' => array('label' => &$GLOBALS['TL_LANG']['tl_member']['loginLinkGen'], 'inputType' => 'checkbox', 'eval' => array('tl_class' => 'clr', 'submitOnChange' => \true), 'save_callback' => array(array('tl_loginLink', 'loginLinkGen')), 'sql' => "int(1) unsigned NOT NULL default '0'")));

Can you recognize anything from this?

rustykowski commented 1 month ago

sorry, @qzminski this is a problem with contao-loginlink V. 1.0.11, the problem disappears after a downgrade.

thescrat commented 1 month ago

Dann stammt das doch aus meiner Erweiterung. In der Master besteht der Fehler nicht, nur im Branch der 4.13, da hier noch nicht mit dem PaletteManipulator gearbeitet wurde. Hab gerade nen neues Release veröffentlich 1.0.12 (ist exakt der Stand aus der Master). Probier das mal aus @rustykowski

rustykowski commented 1 month ago

ja, sehr gut, kein warmup-Fehler mehr. Danke @thescrat!