Skip to content

Comments

Added external code coverage using Travis and Scrutinizer#3

Merged
leofeyer merged 1 commit intocontao:feature/symfony2from
aschempp:feature/code-coverage
Oct 28, 2014
Merged

Added external code coverage using Travis and Scrutinizer#3
leofeyer merged 1 commit intocontao:feature/symfony2from
aschempp:feature/code-coverage

Conversation

@aschempp
Copy link
Member

No description provided.

@leofeyer leofeyer merged commit f69b3e7 into contao:feature/symfony2 Oct 28, 2014
@aschempp aschempp deleted the feature/code-coverage branch October 28, 2014 11:47
@leofeyer leofeyer modified the milestone: 4.0.0 Oct 29, 2014
leofeyer pushed a commit that referenced this pull request Oct 22, 2015
@goransi goransi mentioned this pull request Feb 1, 2018
leofeyer pushed a commit that referenced this pull request Nov 1, 2019
…es command (see #866)

Description
-----------

Together with @Toflar we had a hard time debugging why the `contao:resize-images` command stopped at some point and did not want to continue. The error message was quite unclear especially that the requested file existed:

```
6/77b26349-9084f1ba.jpg......... failed
Unable to open image /var/www/vhosts/domain.tld/httpdocs/releases/233/assets/images/../../var/pim-images/77b26349.jpg
```

So we decided to introduce an option that allows to output more verbose error message simply by executing command in verbose mode `contao:resize-images -v`:

```
f/8ac5c4ec-213df40b.jpg.............. failed

 [ERROR] ImagickException: cache resources exhausted
         `/var/www/vhosts/domain.tld/httpdocs/releases/233/assets/images/../../var/pim-images/8ac5c4ec.jpg' @
         error/cache.c/OpenPixelCache/3864 in
         /var/www/vhosts/domain.tld/httpdocs/releases/233/vendor/imagine/imagine/src/Imagick/Imagine.php:69
         Stack trace:
         #0 /var/www/vhosts/domain.tld/httpdocs/releases/233/vendor/imagine/imagine/src/Imagick/Imagine.php(69):
         Imagick->__construct('/var/www/vhosts...')
         #1 /var/www/vhosts/domain.tld/httpdocs/releases/233/vendor/contao/image/src/Resizer.php(93):
         Imagine\Imagick\Imagine->open('/var/www/vhosts...')
         #2 /var/www/vhosts/domain.tld/httpdocs/releases/233/vendor/contao/image/src/DeferredResizer.php(185):
         Contao\Image\Resizer->executeResize(Object(Contao\Image\Image), Object(Contao\Image\ResizeCoordinates),
         '/var/www/vhosts...', Object(Contao\Image\ResizeOptions))
         #3 /var/www/vhosts/domain.tld/httpdocs/releases/233/vendor/contao/image/src/DeferredResizer.php(108):
         Contao\Image\DeferredResizer->executeDeferredResize('f/8ac5c4ec-213d...', Array,
         Object(Imagine\Imagick\Imagine))
         #4
         /var/www/vhosts/domain.tld/httpdocs/releases/233/vendor/contao/core-bundle/src/Command/ResizeImagesComma
         nd.php(189): Contao\Image\DeferredResizer->resizeDeferredImage(Object(Contao\Image\DeferredImage), false)
         #5
         /var/www/vhosts/domain.tld/httpdocs/releases/233/vendor/contao/core-bundle/src/Command/ResizeImagesComma
         nd.php(166): Contao\CoreBundle\Command\ResizeImagesCommand->resizeImage('f/8ac5c4ec-213d...',
         Object(Symfony\Component\Console\Style\SymfonyStyle))
         #6 /var/www/vhosts/domain.tld/httpdocs/releases/233/vendor/symfony/console/Command/Command.php(255):
```

Commits
-------

e9c6de99 Allow to output more verbose error messages in contao:resize-images command
leofeyer pushed a commit that referenced this pull request Aug 4, 2020
Description
-----------

With @Toflar we have discovered by accident that if a URL is double-encoded (for some reason, doesn't matter) the Contao's `RouteProvider` will eventually throw an error trying to query a database.

```
URL original: drachenlochmuseum-v%25c3%25a4ttis.html
URL decoded: drachenlochmuseum-v%c3%a4ttis.html
URL decoded 2nd time: drachenlochmuseum-vättis.html
```

The decoded URL is used in the database query and that fails because the database driver would like to replace wildcards `%c` with parameters that were not provided.

Stack trace:

```
Exception: Too few arguments to build the query string
#27 vendor/contao/core-bundle/src/Resources/contao/library/Contao/Database/Statement.php(304): replaceWildcards
#26 vendor/contao/core-bundle/src/Resources/contao/library/Contao/Database/Statement.php(249): execute
#25 vendor/contao/core-bundle/src/Resources/contao/library/Contao/Model.php(1102): find
#24 vendor/contao/core-bundle/src/Resources/contao/library/Contao/Model.php(973): findBy
#23 vendor/contao/core-bundle/src/Framework/Adapter.php(38): __call
#22 vendor/contao/core-bundle/src/Routing/RouteProvider.php(493): findPages
#21 vendor/contao/core-bundle/src/Routing/RouteProvider.php(88): getRouteCollectionForRequest
#20 vendor/contao/core-bundle/src/Routing/LegacyRouteProvider.php(43): getRouteCollectionForRequest
#19 vendor/symfony-cmf/routing/src/NestedMatcher/NestedMatcher.php(141): matchRequest
#18 vendor/contao/core-bundle/src/Routing/Matcher/LegacyMatcher.php(69): matchRequest
#17 vendor/symfony-cmf/routing/src/DynamicRouter.php(271): matchRequest
#16 vendor/symfony-cmf/routing/src/ChainRouter.php(188): doMatch
#15 vendor/symfony-cmf/routing/src/ChainRouter.php(158): matchRequest
#14 vendor/symfony/http-kernel/EventListener/RouterListener.php(115): onKernelRequest
#13 vendor/symfony/event-dispatcher/EventDispatcher.php(212): doDispatch
#12 vendor/symfony/event-dispatcher/EventDispatcher.php(44): dispatch
#11 vendor/symfony/http-kernel/HttpKernel.php(126): handleRaw
#10 vendor/symfony/http-kernel/HttpKernel.php(67): handle
#9 vendor/symfony/http-kernel/Kernel.php(198): handle
#8 vendor/symfony/http-kernel/HttpCache/SubRequestHandler.php(85): handle
#7 vendor/symfony/http-kernel/HttpCache/HttpCache.php(448): forward
#6 vendor/symfony/framework-bundle/HttpCache/HttpCache.php(57): forward
#5 vendor/symfony/http-kernel/HttpCache/HttpCache.php(420): fetch
#4 vendor/contao/manager-bundle/src/HttpKernel/ContaoCache.php(46): fetch
#3 vendor/symfony/http-kernel/HttpCache/HttpCache.php(317): lookup
#2 vendor/symfony/http-kernel/HttpCache/HttpCache.php(192): handle
#1 vendor/friendsofsymfony/http-cache/src/SymfonyCache/EventDispatchingHttpCache.php(98): handle
#0 web/app.php(58): null
```

Commits
-------

8ae25820 Fix a potential error if the URL has percentage in it
8caaf252 Fix unit tests
509f7624 Correctly encode the page aliases
leofeyer pushed a commit that referenced this pull request Mar 4, 2021
Description
-----------

Fixes #2787 ([thread](https://community.contao.org/de/showthread.php?80310-Internal-Server-Error-beim-Dr%C3%BCcken-auf-quot-Auswahl-%C3%A4ndern-quot-bei-der-Weiterleitungsseite&p=540163&viewfull=1#post540163)):

```
TypeError:
preg_replace(): Argument #3 ($subject) must be of type array|string, null given

  at vendor/contao/core-bundle/src/EventListener/DataContainer/ContentCompositionListener.php:107
  at preg_replace()
     (vendor/contao/core-bundle/src/EventListener/DataContainer/ContentCompositionListener.php:107)
  at Contao\CoreBundle\EventListener\DataContainer\ContentCompositionListener->renderPageArticlesOperation()
     (vendor/contao/core-bundle/src/Resources/contao/classes/DataContainer.php:804)
  at Contao\DataContainer->generateButtons()
     (vendor/contao/core-bundle/src/Resources/contao/drivers/DC_Table.php:4028)
  at Contao\DC_Table->generateTree()
     (vendor/contao/core-bundle/src/Resources/contao/drivers/DC_Table.php:3628)
  at Contao\DC_Table->treeView()
     (vendor/contao/core-bundle/src/Resources/contao/drivers/DC_Table.php:353)
  at Contao\DC_Table->showAll()
     (vendor/contao/core-bundle/src/Resources/contao/classes/Backend.php:644)
  at Contao\Backend->getBackendModule()
     (vendor/contao/core-bundle/src/Resources/contao/controllers/BackendMain.php:167)
  at Contao\BackendMain->run()
     (vendor/contao/core-bundle/src/Controller/BackendController.php:48)
  at Contao\CoreBundle\Controller\BackendController->mainAction()
     (vendor/symfony/http-kernel/HttpKernel.php:158)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw()
     (vendor/symfony/http-kernel/HttpKernel.php:80)
  at Symfony\Component\HttpKernel\HttpKernel->handle()
     (vendor/symfony/http-kernel/Kernel.php:201)
  at Symfony\Component\HttpKernel\Kernel->handle()
     (web/index.php:31)
```

Since `$icon` can specifically be null. Not sure why it would be though in this specific instance, but apparently it can happen.

Commits
-------

1f5fa9d4 check if icon is null
d3f84251 return empty string if href and icon are missing
a6d128a1 Merge branch '4.11' into fix-content-composition-listener-if-icon-is-null
7fc31595 Update core-bundle/src/EventListener/DataContainer/ContentCompositionListener.php

Co-authored-by: Leo Feyer <github@contao.org>
69243b64 Correctly merge image size _defaults (see #2783)

Description
-----------

| Q                | A
| -----------------| ---
| Fixed issues     | -
| Docs PR or issue | -

Currently defining `formats` under the image size `_defaults` is broken. This is because the processed config values of the individual size definitions already contain an empty `formats` array which then wins in  `array_merge`. This PR fixes this problem by giving the values under `_defaults` precedence over empty arrays.

Unfortunately this case was missing from the tests and went unnoticed (added now)…

Commits
-------

b7b7b601 merge _defaults with precedence over empty arrays
990be331 add reference
af36ec25 Merge branch '4.11' into bugfix/image-size-defaults-empty-arrays
aafb7622 Suggest using the contao-setup binary with @php prefix (see #2796)

Description
-----------

| Q                | A
| -----------------| ---
| Fixed issues     | Fixes #2776 
| Docs PR or issue | -

related contao/managed-edition#57

Commits
-------

b1bd1850 suggest using the prefixed contao-setup binary
9cfd8c6c fix accessing undefined variable (see #2806)

Description
-----------

| Q                | A
| -----------------| ---
| Fixed issues     | Fixes #...
| Docs PR or issue | contao/docs#...

Sigh, another one for PHP8.

Fixes 
```
Warning: Undefined array key "breadcrumb"
```
after clicking on the articles selection in the page tree because the `sorting` array does not contain `breadcrumb`.

Commits
-------

36dcf5e6 fix accessing undefined variable
fdbc6b8a Correctly sort pages if the URL suffix is empty (see #2784)

Description
-----------

| Q                | A
| -----------------| ---
| Fixed issues     | Fixes #2775

Apparently, `substr('foo', 0, -0)` is empty 🙈

Commits
-------

502a0e03 Correctly sort pages on empty URL suffix
aa5fe3b3 Merge branch '4.11' into bugfix/folderurl
f16cbfc3 Fix accessing Model\Collection instead of Model in ModuleFaqPage (see #2788)

Description
-----------

| Q                | A
| -----------------| ---
| Fixed issues     | Fixes #2786 
| Docs PR or issue | -

`$figureBuilder->setMetadata($objFaq->getOverwriteMetadata())` was failing because `$objFaq` is a `Model\Collection` instead of a `Model`. To prevent this rather hard to spot error in the future, I adjusted how we're iterating over the results instead.

Commits
-------

ff2f8b9d iterate over FaqModels instead of operating on Model\Collection
c2934f0c Merge branch '4.11' into bugfix/module-faq-model-collection
51107f07 Handle another illegal array access in the tl_page DCA (see #2794)

Description
-----------

| Q                | A
| -----------------| ---
| Fixed issues     | Fixes -
| Docs PR or issue | -

This fixes `Warning: Undefined array key "root"` coming from `DCTable` line 3669. This also hardens `tl_page#pastePage()` that will receive an incomplete `$row` by the call in line 3678 and would otherwise produce `Warning: Undefined array key "pid"`.

https://github.com/contao/contao/blob/1873bcc9ea728a08ca8755f6e7251d999d7b316b/core-bundle/src/Resources/contao/drivers/DC_Table.php#L3669-L3690

Commits
-------

7e5b39f2 handle illegal array access
5ff8b5f4 simplify expression

Co-authored-by: Leo Feyer <github@contao.org>
aaa71e18 Fix the logout handler in Symfony 5 (see #2818)

Description
-----------

This PR fixes the following error in Contao **4.11.0**:

```
TypeError:
Argument 2 passed to Contao\CoreBundle\Security\Logout\LogoutHandler::logout() must be an instance of Symfony\Component\HttpFoundation\Response, null given, called in vendor\symfony\security-bundle\Security\LegacyLogoutHandlerListener.php on line 42

  at vendor\contao\contao\core-bundle\src\Security\Logout\LogoutHandler.php:50
  at Contao\CoreBundle\Security\Logout\LogoutHandler->logout()
     (vendor\symfony\security-bundle\Security\LegacyLogoutHandlerListener.php:42)
  at Symfony\Bundle\SecurityBundle\Security\LegacyLogoutHandlerListener->onLogout()
     (vendor\symfony\event-dispatcher\EventDispatcher.php:270)
  at Symfony\Component\EventDispatcher\EventDispatcher::Symfony\Component\EventDispatcher\{closure}()
     (vendor\symfony\event-dispatcher\EventDispatcher.php:230)
  at Symfony\Component\EventDispatcher\EventDispatcher->callListeners()
     (vendor\symfony\event-dispatcher\EventDispatcher.php:59)
  at Symfony\Component\EventDispatcher\EventDispatcher->dispatch()
     (vendor\symfony\security-http\Firewall\LogoutListener.php:122)
  at Symfony\Component\Security\Http\Firewall\LogoutListener->authenticate()
     (vendor\symfony\security-bundle\Debug\WrappedLazyListener.php:49)
  at Symfony\Bundle\SecurityBundle\Debug\WrappedLazyListener->authenticate()
     (vendor\symfony\security-http\Firewall\AbstractListener.php:26)
  at Symfony\Component\Security\Http\Firewall\AbstractListener->__invoke()
     (vendor\symfony\security-bundle\Debug\TraceableFirewallListener.php:62)
  at Symfony\Bundle\SecurityBundle\Debug\TraceableFirewallListener->callListeners()
     (vendor\symfony\security-http\Firewall.php:86)
  at Symfony\Component\Security\Http\Firewall->onKernelRequest()
     (vendor\symfony\event-dispatcher\Debug\WrappedListener.php:117)
  at Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke()
     (vendor\symfony\event-dispatcher\EventDispatcher.php:230)
  at Symfony\Component\EventDispatcher\EventDispatcher->callListeners()
     (vendor\symfony\event-dispatcher\EventDispatcher.php:59)
  at Symfony\Component\EventDispatcher\EventDispatcher->dispatch()
     (vendor\symfony\event-dispatcher\Debug\TraceableEventDispatcher.php:151)
  at Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch()
     (vendor\symfony\http-kernel\HttpKernel.php:133)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw()
     (vendor\symfony\http-kernel\HttpKernel.php:79)
  at Symfony\Component\HttpKernel\HttpKernel->handle()
     (vendor\symfony\http-kernel\Kernel.php:195)
  at Symfony\Component\HttpKernel\Kernel->handle()
     (web\index.php:31)
  at require('web\\index.php')
     (web\app.php:4)           
```

**Reproduction**:

1. Create a login form, login page and member.
2. Create a logout page.
3. Log into the front end.
4. Use the link in the menu for the logout.

Apparently the `LogoutEvent` might not contain a `Response` object any more.

Commits
-------

aa5b2e8d fix argument error in Symfony 5
bd06335f Merge branch '4.11' into fix-logout-handler
e1f1e8de Fix an illegal array access in DC_Table when expanding the tree (see #2805)

Description
-----------

| Q                | A
| -----------------| ---
| Fixed issues     | Fixes #2797 
| Docs PR or issue | -

I split the PR in two commits:
* one that *only* formats the code so that there is any chance of reviewing this:
contao/contao@a1a16fe
* one that applies the fixes:
contao/contao@9bcedb7

(If you want to, I can collapse the whole thing into a oneline-mega-expression again in a third one…)

Commits
-------

a1a16fea format call
9bcedb79 fix illegal array access
2f22b2fc collapse expression
01a9a391 Allow passing an array of IDs to User::isMemberOf() (see #2834)

Description
-----------

| Q                | A
| -----------------| ---
| Fixed issues     | Fixes #2753
| Docs PR or issue | -

To fix #2753 (do not show protected pages in the sitemap if there is no front end user or the user groups do not match), I have adjusted the `User::isMemberOf()` method to also accept an array of group IDs. This allows us to greatly simplify other checks as well:

### Current

```php
$blnFeUserLoggedIn = System::getContainer()->get('contao.security.token_checker')->hasFrontendUser();

while ($objCalendar->next())
{
	if ($objCalendar->protected)
	{
		if (!$blnFeUserLoggedIn || !\is_array($this->User->groups))
		{
			continue;
		}

		$groups = StringUtil::deserialize($objCalendar->groups);

		if (empty($groups) || !\is_array($groups) || \count(array_intersect($groups, $this->User->groups)) < 1)
		{
			continue;
		}
	}

	// …
}
```

### New

```php
$user = null;

if (System::getContainer()->get('contao.security.token_checker')->hasFrontendUser())
{
	$user = FrontendUser::getInstance();
}

while ($objCalendar->next())
{
	if ($objCalendar->protected && (!$user || !$user->isMemberOf(StringUtil::deserialize($objCalendar->groups))))
	{
		continue;
	}

	// …
}
```

Commits
-------

9a924c38 Allow passing an array of IDs to User::isMemberOf()
c5c39ae6 add some unit tests
2db757c7 Merge branch '4.11' into fix-content-composition-listener-if-icon-is-null
leofeyer pushed a commit that referenced this pull request Mar 15, 2021
Description
-----------

| Q                | A
| -----------------| ---
| Fixed issues     | partly solves #2316 
| Docs PR or issue | -

I'm working on test isolation. This part makes sure tests aren't reading temporary data from each other. This effectively means that a test should never write into the `Fixtures` dir (or anywhere else inside the source directories). If temporary files need to be created this now will happen inside the test's own `tmp` dir.

While working on these files, I'm also adjusting the following for consistency:

1) Refactoring path operations to use `Path`
1) Removing private property `$filesystem`  (if we want to share the `Filesystem` instance across tests, we should imo add it to `ContaoTestCase` as a static property)
1) Use `$filesystem` instead of `$fs` everywhere

Following changes needed for #2316 (but unrelated to writing files) are also part of this PR:

1) Reset template loader every time (was missing once, now in `tearDown`).
1) Do not share `ContaoCacheWarmer` instance.

Commits
-------

4e5fa522 never write into tests/Fixture dir
baf27c49 always reset TemplateLoader
827d5f27 add missing file
c3c0e628 backport changes from #1918
2aeb2eeb CS
79272861 Merge branch '4.9' into bugfix/test-order/do-not-write-in-fixture-dir
a50db5c1 Fix the prefer-lowest tests
71e7cfa7 clear var directory after running functional tests
c466d7e5 bugfix for bugfix/test-order/do-not-write-in-fixture-dir
3b4fdb40 Merge pull request #2 from fritzmg/fix-bugfix/test-order/do-not-write-in-fixture-dir

bugfix for bugfix/test-order/do-not-write-in-fixture-dir
9891c55f fix filepath comparisons
a25d552e Merge pull request #3 from fritzmg/fix-imagefactorytest-filepath-comparisons

Fix filepath comparisons
leofeyer pushed a commit that referenced this pull request Jun 7, 2021
Description
-----------

This PR

* ensures the new `ResponseContext` does contain clean and unencoded values in preparation for the future (one thing less to migrate)
* unifies the handling of insert tags for meta description. Sometimes it was stripped, sometimes replaced

Commits
-------

3b9922c8 Ensure clean response context and unify meta handling
6b286598 Move description shortening to template
ee9eedff Add StringUtil::getRawDecodedValue()
f7969ba1 Add StringUtil::getRawDecodedValueFromHtml()
5821b918 Test and fix getRawDecodedValueFromHtml method
84a80bdd Fix tests
7980cdaa Improve insert tag braces encoding
bd105385 Merge pull request #2 from ausi/fix/response-context-encoding
1054d98f Use our own string util to shorten the description
a5586c0e CS
3bd69849 Improve string util test
cbd11c42 Merge pull request #3 from ausi/fix/improve-string-util-test
4dc2d384 CS
5a5578f8 Rename to StringUtil methods
207df742 CS
leofeyer added a commit that referenced this pull request Nov 29, 2021
Description
-----------

@m-vo @ausi I am not sure how to fix the remaining 10 issues:

<img width="1183" alt="" src="https://user-images.githubusercontent.com/1192057/143582970-6915b42f-a754-4760-9d75-27508c710f2f.png">

Any idea?

Commits
-------

93b26210 Unlock PHPStan level 6
08fcf194 Fix PHPStan
2e46f7a8 Adjust the FigureBuilder::setLinkAttribute() method
4856530d Fix two wrong @param annotations
5cef696c Fix two errors
77979af4 Merge branch '4.x' into fix/phpstan6
db8023da More PHPStan changes (see #3)
leofeyer pushed a commit that referenced this pull request Dec 2, 2021
Description
-----------

See contao/contao#3743 (comment)

Commits
-------

292c5a1d Unify MakeServicesPublicPass
797a4e74 Sort the IDs
9fc88f20 Do not call getDefinition() if the service ID is an alias (#3)
leofeyer added a commit that referenced this pull request Dec 9, 2021
Description
-----------

| Q                | A
| -----------------| ---
| Fixed issues     | Fixes #3415
| Docs PR or issue | -

This PR implements the discussed solution for not generating any routes for the special `error_*` page types. The `PageRegistry` will throw a `RouteNotFoundException` when the route for any of the `error_*` pages is retrieved. The "non-routable" page types are hard coded in the `PageRegistry`, similar to the legacy page types which do not have content composition (`PageRegistry::DISABLE_CONTENT_COMPOSITION` & `PageRegistry::DISABLE_ROUTING`).

Additionally the `SitemapController` checks the `_format` of the processed page and only adds pages with `html` content to the sitemap.

Commits
-------

b4c077c4 do not create routes for error pages
07621be7 only add html routes to the sitemap
8d293309 add test for PageRegistry
dc1ddbb3 introduce UnroutablePageRouteCompiler
2b244593 add comment
9702ab7a fix functional tests
8f64d974 update all navigation modules
784b85f6 fix SitemapControllerTest after 4.x rebase
ea6eca4f fix custom nav and change quick link
09991774 fix return type in breadcrumb
8e65d7ee merge with 4.x
aca2257d move isRoutable check to page registry
e79e4507 CS
d8cdf7aa fix Route404ProviderTest
178ad6b2 Merge branch '4.x' into no-routes-for-error-pages
edc70cad revert changes to navigation modules
e1a7b86c allow RouteConfig path to be boolean
1da20f9d code style
24d1c61a Merge branch '4.x' into no-routes-for-error-pages
e212e63e Various improvements (#3)
ed32cc44 merge with 4.x
582ecff9 code style
ccb85c3a allow preview for non-routable pages, if they support content composition
effb8d3c Revert "allow preview for non-routable pages, if they support content composition"

This reverts commit ccb85c3a66bcb5ae87d31ca6342770aa1c35260a.
aaea5a57 satisfy PHPstan
0e4c098b use consistent variable naming
011ebb17 Merge branch '4.x' into no-routes-for-error-pages
66ef9f8d fix type hint

Co-authored-by: Leo Feyer <github@contao.org>
abba5260 do not check for route instance
cda07cef CS
7c16a221 fix return type
35dbc230 CS
leofeyer pushed a commit that referenced this pull request Jan 4, 2024
Description
-----------

Description (and possibily title) could be nullable fields in the database. I got the following error from calling `StringUtil::substr` on the value:

```
Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
```

see https://terminal42.sentry.io/share/issue/fbb102c0dc534b939824576c09de1bc1/

Commits
-------

cac0d060 Fix NULL handling in SerpPreview
leofeyer pushed a commit that referenced this pull request May 29, 2024
… #7248)

Description
-----------

If a `tl_article` record still contains `keywords` from previous Contao versions and you reference this article in an `article` content element, the following warning will appear in the back end:

```
ErrorException: Warning: Undefined global variable $TL_KEYWORDS
#24 /vendor/contao/core-bundle/src/Resources/contao/modules/ModuleArticle.php(207): Contao\ModuleArticle::compile
#23 /vendor/contao/core-bundle/src/Resources/contao/modules/Module.php(214): Contao\Module::generate
#22 /vendor/contao/core-bundle/src/Resources/contao/modules/ModuleArticle.php(70): Contao\ModuleArticle::generate
#21 /vendor/contao/core-bundle/src/Resources/contao/library/Contao/Controller.php(550): Contao\Controller::getArticle
#20 /vendor/contao/core-bundle/src/Resources/contao/elements/ContentArticle.php(30): Contao\ContentArticle::generate
#19 /vendor/contao/core-bundle/src/Resources/contao/library/Contao/Controller.php(622): Contao\Controller::getContentElement
#18 /var/cache/prod/contao/dca/tl_content.php(318): tl_content::addCteType
#17 /vendor/contao/core-bundle/src/Resources/contao/drivers/DC_Table.php(4717): Contao\DC_Table::parentView
#16 /vendor/contao/core-bundle/src/Resources/contao/drivers/DC_Table.php(313): Contao\DC_Table::showAll
#15 /vendor/contao/core-bundle/src/Resources/contao/classes/Backend.php(667): Contao\Backend::getBackendModule
#14 /vendor/contao/core-bundle/src/Resources/contao/controllers/BackendMain.php(168): Contao\BackendMain::run
#13 /vendor/contao/core-bundle/src/Controller/BackendController.php(49): Contao\CoreBundle\Controller\BackendController::mainAction
#12 /vendor/symfony/http-kernel/HttpKernel.php(163): Symfony\Component\HttpKernel\HttpKernel::handleRaw
#11 /vendor/symfony/http-kernel/HttpKernel.php(75): Symfony\Component\HttpKernel\HttpKernel::handle
#10 /vendor/symfony/http-kernel/Kernel.php(202): Symfony\Component\HttpKernel\Kernel::handle
#9 /vendor/symfony/http-kernel/HttpCache/SubRequestHandler.php(86): Symfony\Component\HttpKernel\HttpCache\SubRequestHandler::handle
#8 /vendor/symfony/http-kernel/HttpCache/HttpCache.php(481): Symfony\Component\HttpKernel\HttpCache\HttpCache::forward
#7 /vendor/symfony/framework-bundle/HttpCache/HttpCache.php(73): Symfony\Bundle\FrameworkBundle\HttpCache\HttpCache::forward
#6 /vendor/symfony/http-kernel/HttpCache/HttpCache.php(454): Symfony\Component\HttpKernel\HttpCache\HttpCache::fetch
#5 /vendor/contao/manager-bundle/src/HttpKernel/ContaoCache.php(66): Contao\ManagerBundle\HttpKernel\ContaoCache::fetch
#4 /vendor/symfony/http-kernel/HttpCache/HttpCache.php(348): Symfony\Component\HttpKernel\HttpCache\HttpCache::lookup
#3 /vendor/symfony/http-kernel/HttpCache/HttpCache.php(226): Symfony\Component\HttpKernel\HttpCache\HttpCache::handle
#2 /vendor/friendsofsymfony/http-cache/src/SymfonyCache/EventDispatchingHttpCache.php(96): Contao\ManagerBundle\HttpKernel\ContaoCache::handle
#1 /web/index.php(44): require
#0 /web/app.php(13): null
```

This is because `$GLOBALS['TL_KEYWORDS']` is only initialised in the front end within `PageRegular::prepare()`. This PR simply ignores it if not set.

Commits
-------

e54dc2b8 fix warning when legacy keywords are present
leofeyer pushed a commit that referenced this pull request Jun 7, 2024
…#7268)

Description
-----------

Got this erro in my logs:

```
RuntimeException: The Symfony container is not available, did you initialize the Contao framework? in vendor/contao/core-bundle/contao/library/Contao/System.php:143 Stack trace:
#0 vendor/contao/core-bundle/contao/library/Contao/System.php(97): Contao\System->import('Contao\\Config', 'Config')
#1 vendor/contao/core-bundle/contao/library/Contao/DcaExtractor.php(105): Contao\System->__construct()
#2 vendor/contao/core-bundle/contao/library/Contao/DcaExtractor.php(140): Contao\DcaExtractor->__construct('tl_opt_in')
#3 vendor/contao/core-bundle/contao/library/Contao/Model.php(291): Contao\DcaExtractor::getInstance('tl_opt_in')
#4 vendor/contao/core-bundle/contao/library/Contao/Model.php(1084): Contao\Model::getUniqueFields()
#5 vendor/contao/core-bundle/contao/models/OptInModel.php(87): Contao\Model::findBy(Array, 1716888783, Array)
#6 vendor/contao/core-bundle/src/Framework/Adapter.php(38): Contao\OptInModel::findExpiredTokens()
#7 vendor/contao/core-bundle/src/OptIn/OptIn.php(76): Contao\CoreBundle\Framework\Adapter->__call('findExpiredToke...', Array)
#8 vendor/contao/core-bundle/src/Cron/PurgeOptInTokensCron.php(30): Contao\CoreBundle\OptIn\OptIn->purgeTokens()
#9 vendor/contao/core-bundle/src/Cron/CronJob.php(44): Contao\CoreBundle\Cron\PurgeOptInTokensCron->__invoke('cli')
#10 vendor/contao/core-bundle/src/Cron/Cron.php(197): Contao\CoreBundle\Cron\CronJob->__invoke('cli')
#11 vendor/contao/core-bundle/src/Cron/Cron.php(182): Contao\CoreBundle\Cron\Cron->executeCrons(Array, 'cli', Object(Closure))
#12 vendor/contao/core-bundle/src/Cron/Cron.php(97): Contao\CoreBundle\Cron\Cron->doRun(Array, 'cli', false)
#13 vendor/contao/core-bundle/src/Command/CronCommand.php(53): Contao\CoreBundle\Cron\Cron->run('cli', false)
#14 vendor/symfony/console/Command/Command.php(326): Contao\CoreBundle\Command\CronCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 vendor/symfony/console/Application.php(1096): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 vendor/symfony/framework-bundle/Console/Application.php(126): Symfony\Component\Console\Application->doRunCommand(Object(Contao\CoreBundle\Command\CronCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 vendor/symfony/console/Application.php(324): Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand(Object(Contao\CoreBundle\Command\CronCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 vendor/symfony/framework-bundle/Console/Application.php(80): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#19 vendor/symfony/console/Application.php(175): Symfony\Bundle\FrameworkBundle\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#20 vendor/contao/manager-bundle/bin/contao-console(40): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput))
#21 vendor/bin/contao-console(119):  #22
```

Commits
-------

9ee76a07 Initialize the Contao framework when working with opt-in tokens
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants