Visitar URL original
Added unit tests for autoloading component by Toflar · Pull Request #4 · contao/core-bundle · GitHub
Skip to content

Added unit tests for autoloading component - #4

Merged
leofeyer merged 1 commit into
contao:feature/symfony2from
Toflar:feature/sf2-autoload-unittests
Oct 28, 2014
Merged

leofeyer merged 1 commit into
contao:feature/symfony2from
Toflar:feature/sf2-autoload-unittests

Conversation

@Toflar

@Toflar Toflar commented Oct 28, 2014

Copy link
Copy Markdown
Member

No description provided.

@leofeyer
leofeyer merged commit b478961 into contao:feature/symfony2 Oct 28, 2014
@leofeyer leofeyer added this to the 4.0.0 milestone Oct 28, 2014
leofeyer pushed a commit that referenced this pull request Nov 7, 2014
Added import and export feature, adjusted description, checked final todo's
discordier pushed a commit to discordier/core-bundle that referenced this pull request Apr 10, 2015
Added import and export feature, adjusted description, checked final todo's
leofeyer pushed a commit that referenced this pull request Jul 24, 2015
Added import and export feature, adjusted description, checked final todo's
leofeyer pushed a commit that referenced this pull request Aug 26, 2016
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 Jun 14, 2021
Description
-----------

Alternative approach for response context as discussed in Core team call.
I guess there's no point in explaining it all here - I'll just document the final iteration once everything is done in the Contao dev docs ^^

Commits
-------

205dafc7 Reworked response context concept
786b50ca Merge branch '4.x' into feature/response-context-rework
4d1cf189 CS
d2151bb4 Fixed tests
aae10917 Implemented removing existing services and added support for interfaces
0a83cbe4 Added psalm docs
5f27ffce Make HtmlHeadBag final
5e75e386 CS
950e9bbe Also consider parent classes as aliases
fbe8206c Going back to a regular array and removed the remove() method
41b1c60f Added support for lazy services
8a35bc96 Fixed tests
0d7f8d93 CS

Co-authored-by: Leo Feyer <github@contao.org>
5b9706c4 Added failing test to show class issue
d37a2237 Merge pull request #4 from aschempp/feature/response-context-rework

Added failing test to show class issue
f0a1f353 Removed irrelevant assertion
1d29c95c Fixed tests
6399cc78 Cleanup
12556327 Fixed phpstan
6a1eebc4 CS
e90daf48 Added failing test to show alias being overridden
a5c95893 Merge pull request #5 from aschempp/feature/response-context-rework

Added failing test to show alias being overridden
1cb74c7a Fixed tests
84af804d Removed leftover
62cb0af1 CS
leofeyer added a commit that referenced this pull request Jan 17, 2022
Description
-----------

To-Do
-----

- [x] Naming
- [x] Tests

The idea is to get rid of multiple page layouts (or inserttags with module IDs in combination with `{{iflng::*}}` tags) for multiple root pages (and languages).

Usage
-----

You can now easy configure you modules for every root page available:

<img width="1232" alt="Bildschirmfoto 2021-12-15 um 22 36 21" src="https://user-images.githubusercontent.com/754921/146269104-58ae3bb8-f818-495b-8bd1-fa771213f4c4.png">


and include this module in your layout: 

<img width="830" alt="Bildschirmfoto 2021-12-15 um 22 39 41" src="https://user-images.githubusercontent.com/754921/146269130-9ede184a-c4d4-4efe-be76-7177a1c5255d.png">


This module will then render the configured module for each configured root page. 

Developers
----------

The module provides an additional input type to use in your own code:

**Use the default configuration** (loads all available modules):
```php
<?php
// config/dca/tl_modules.php

$GLOBALS['TL_DCA']['tl_module']['fields'] += [
    'myRootPageDependentModule' => [
        'inputType' => 'rootPageDependentSelect',
        'eval' => [
            'tl_class' => 'w50',
        ],
        'sql' => 'blob NULL',
    ],
];
```

There is even more and you can customize this widget to your needs:

**use `options`** (for custom list of modules):
```php
<?php
// config/dca/tl_modules.php

$GLOBALS['TL_DCA']['tl_module']['fields'] += [
    'myRootPageDependentModule' => [
        'inputType' => 'rootPageDependentSelect',
        'options' => [
            0 => 'My module 0',
            1 => 'My module 1',
        ],
        'eval' => [
            'tl_class' => 'w50',
        ],
        'sql' => 'blob NULL',
    ],
];
```

**use `options_callback`** (for custom list of modules):
```php
<?php
// config/dca/tl_modules.php

$GLOBALS['TL_DCA']['tl_module']['fields'] += [
    'myRootPageDependentModule' => [
        'inputType' => 'rootPageDependentSelect',
        'options_callback' => ['my.service_id', 'methodName'],
        'eval' => [
            'tl_class' => 'w50',
        ],
        'sql' => 'blob NULL',
    ],
];

// you can also use this with service tagging, see https://docs.contao.org/dev/framework/dca/#registering-callbacks
```

**use `eval['modules']`** (to filter for custom types):
```php
<?php
// config/dca/tl_modules.php

$GLOBALS['TL_DCA']['tl_module']['fields'] += [
    'myRootPageDependentModule' => [
        'inputType' => 'rootPageDependentSelect',
        'eval' => [
            'tl_class' => 'w50',
            'modules' => [
                'navigation',
                'customnav',
                'search',
                'html',
                'myCustomModule',
            ],
        ],
        'sql' => 'blob NULL',
    ],
];
```

**Change the label for the blank option**:
```php
<?php
// config/dca/tl_modules.php

$GLOBALS['TL_DCA']['tl_module']['fields'] += [
    'myRootPageDependentModule' => [
        'inputType' => 'rootPageDependentSelect',
        'eval' => [
            'tl_class' => 'w50',
            'blankOptionLabel' => 'My Label'
        ],
        'sql' => 'blob NULL',
    ],
];
```

_Note:_ If you just want to change the label for the blank option of the default field, the key is: `tl_module.rootPageDependentModulesBlankOptionLabel`.

Commits
-------

b637e979 Add new language dependent module
056913d6 Fix method name
0d9824be Make it root page dependent
d78957c7 Remove loadLanguageFile call
214fd315 Remove use
7c8b11bd Move configuration to DCA file
91235b87 Fix merge services.yml
7447cde1 Fix merge of listener.yml
f09c2318 Fix listener.yml
8dd0d757 Fix services.yml
acfb8cf1 Fixes
16720607 Fix CS
ad83e0dd Fix listener.yml
4bd2ead2 Fix services.yml
e8d2d79f Merge branch '4.x' of github.com:contao/contao into feature/language-dependent-module-configuration
83aab2e3 Fix sorting
127497d1 Merge branch '4.x' of github.com:contao/contao into feature/language-dependent-module-configuration
243920b7 Merge branch '4.x' of github.com:contao/contao into feature/language-dependent-module-configuration
67fde19f Add unit test for controller
60822953 More tests
d1e71047 CS
3fcbcc2f CS
0894a402 Remove unused
f6b8d50c Remove obsolete registration
b638dd2c Use Hook annotation
654cd292 Adjust wording
86cbde12 Remove template
e97704c2 Adjust palette
971a70a7 Tag response
6c85b7b8 Use callback annotation
68256d20 Rename and fixes
126ed6ac Rename methods
64833ffb Add test for wizardCallback
a91283f6 Fix CS
8f8cbc78 Fix tests on PHP8
d1a508f9 Cleanup
873e440c Merge branch '4.x' of github.com:contao/contao into feature/language-dependent-module-configuration
d9607546 Test save callback
5c9f0a50 Test options callback
d60e29fa Merge branch '4.x' of github.com:contao/contao into feature/language-dependent-module-configuration
6bbe3f3d CS fix
4d187835 Do not mark for internal caching
99203050 Merge branch '4.x' of github.com:contao/contao into feature/language-dependent-module-configuration
c742a6b6 Refactored logic into widget
0309d6b5 CS
2b801f25 Remove comment
de2b7dc1 Use ContaoCsrfTokenManager
9f56fda6 Search for type='root' instead of pid=0
a4762f93 Simplify
24f07a4d Merge branch '4.x' of github.com:contao/contao into feature/language-dependent-module-configuration
e2174c94 Add widget test
c48ea1b1 CS
a6e54693 Fix CS
d80d5e6d Remove useless mocks
9f2d99df Use PageModels & Collection in test
ae1520cd CS
a562e5d1 CS
f2984b71 Adjusted controller
496e90a5 Remove buggy option groups feature
7b690356 CS
6335a6b3 Extend from AbstractFrontendModuleController (#4)
0442d142 Add test for Controller
728c12fa Register the be_wildcard template in the unit test
91d65594 Canonicalize the path

Co-authored-by: Leo Feyer <github@contao.org>
leofeyer added a commit that referenced this pull request May 9, 2022
Description
-----------

-

Commits
-------

32306fab Fix the global state unit tests
4405ac88 Suggestions for contao/contao#4618 (#4)

Co-authored-by: Martin Auswöger <martin@auswoeger.com>
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