Visitar URL original
Feature/sf2 autoload unittests by discordier · Pull Request #11 · contao/core-bundle · GitHub
Skip to content

Feature/sf2 autoload unittests - #11

Merged
leofeyer merged 3 commits into
contao:feature/symfony2from
discordier:feature/sf2-autoload-unittests
Oct 28, 2014
Merged

leofeyer merged 3 commits into
contao:feature/symfony2from
discordier:feature/sf2-autoload-unittests

Conversation

@discordier

Copy link
Copy Markdown
Contributor

Implement unit test to check that an unparsable ini file indeed throws the RuntimeException even tho a warning is issued.

@leofeyer
leofeyer merged commit 0187178 into contao:feature/symfony2 Oct 28, 2014
@leofeyer leofeyer modified the milestone: 4.0.0 Oct 29, 2014
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 Nov 24, 2021
Description
-----------

Follow up on contao/contao#3594.

This PR provides 3 new commands:

- `contao:backup:create` - to create a new backup
- `contao:backup:restore` - to restore a given backup
- `contao:backup:list` - to list all available backups

Configuration options:

- The maximum number of backups Contao should keep (defaults to `5`).
- The target directory where it should manage the backups (defaults to `var/backups`)
- Tables to ignore for backups (defaults to things like the search index or our crawler queue)

Additional features:

- Our `contao:migrate` command now automatically creates a backup before migrating which makes things a lot safer :-) You can optionally disable it using `--no-backup`.
- `--format=json` support for the `create` and `list` commands for a possible future integration in e.g. the Contao Manager.

Impressions:



<img width="857" alt="Bildschirmfoto 2021-11-01 um 14 04 31" src="https://user-images.githubusercontent.com/481937/139678077-132216f1-1871-438d-9e67-a25d06573cfd.png">
<img width="876" alt="Bildschirmfoto 2021-11-01 um 14 04 50" src="https://user-images.githubusercontent.com/481937/139678092-6a9294d5-86f5-4262-8e25-c6c2a80106d9.png">
<img width="735" alt="Bildschirmfoto 2021-11-01 um 14 05 03" src="https://user-images.githubusercontent.com/481937/139678119-904c3dab-e18a-46ce-97a6-ed18e6cd96ae.png">

ToDo:

- [x] Tests

Commits
-------

cc22a7b3 Implemented a contao:database:import command
8d4f7371 Implemented a contao:database:dump command
cdee0691 Merge branch 'feature/db-dump-command' into feature/db-cli

* feature/db-dump-command:
  Implemented a contao:database:dump command
cbccc8d4 Merge branch 'feature/db-import-command' into feature/db-cli

* feature/db-import-command:
  Implemented a contao:database:import command
a16f8efb CS
f51b5bf9 Dump to var folder by default
84fed4c4 Allow to configure the default tables that are ignored during a db dump
e2d87578 Extracted db dumping logic into service
7b953b8f CS
421bbe24 Create a backup by default when running contao:migrate
d52d4a52 Rename class
08a0d4d6 Huge rework
dad5a8a6 CS
e8dab2b4 CS
a82d0887 Make sure we know when a dump has been generated
24414a85 Switching to backup implementation
c1ef6b53 Ignore comments
9dd390ad Handle creating and restoring backups as transactions
c8754a85 Allow to disable the backup origin check
6e22890e Fixed restore logic
2010573f Added json format
57f44e7d Consider ndjson format in migrate command
56f2c3b7 Added tests for the contao:backup:create command and fixed issues found along the way
f2a2fcba Use previous exception
72abbf77 Be explicit in config
dd913dbe Added tests for contao:backup:list
4ac742c2 Added tests for contao:backup:restore and introduced json support there as well
c6a24126 Added tests for configuration and extension
9b78bc8c Added tests for Backup and fixed issues found along the way
c67270fd Added tests for CreateConfig and RestoreConfig
147dbd9d Validate filepath with a regex
bb18de30 Test everything but restore and dump in BackupManager
7df78853 Extracted dependency on slimdump in favor of a simple interface in order to split deps properly and allow for proper testing and other use cases
f79e04ab Added tests for create method and fixed issue with error handling
67550f7e Typo
eaa281cd Test tidying up directory works as expected and fixed issues found along the way
de9aae97 Finished full coverage for BackupManager
504fe847 Covered last class with unit tests
26fbbb90 Merge branch '4.x' into feature/cli-backups
d64931ce Use Composer OAuth token
c950d5cd Made tests more platform independent
84ba8a20 Revert "Use Composer OAuth token"

This reverts commit d64931cec404cb02e7cafbb011aa198803858efb.
9f8a112e Implemented our own dumper class
dbab5fe2 Fixed definition
fb2e7289 CS
e819afdb Test
cb1b1004 CS
fa794c83 Trying to fix those freakin tests
064e5c7f CS
1e74fe44 fix Windows test issues (#8)
cb0b5502 Remove obsolete comment
52263621 Remove obsolete config option
dc46cf9e Added support for views
583f44d6 Moved responsibility of writing the actual backup files from the dumper to the backupmanager, Generators FTW!
0b9e02ab CS
a6e752f9 Reuse dumper mock
2511bc82 More reuse
0d669948 Improve phpdocs
08d98c8b Improved docs
06083e8e Added support for extending or shortening an existing tables ignore list
5d909578 CS
ccb2defe Merge branch '4.x' into feature/cli-backups
99071440 Update core-bundle/src/Doctrine/Backup/Backup.php

Co-authored-by: Fritz Michael Gschwantner <fmg@inspiredminds.at>
2669df74 Human readable information might be locale dependent and shouldn't be part of the Backup object itself
ec5184d9 Fixed missing ndjson feedback for successful backup creation in contao:migrate
993e4f15 Fixed tests
5d09bc97 Update core-bundle/src/Doctrine/Backup/BackupManager.php

Co-authored-by: Martin Auswöger <martin@auswoeger.com>
bd41a278 Merge branch '4.x' into feature/cli-backups
136909bd CS
e922422a CS (#11)
a11da204 CS
leofeyer added a commit that referenced this pull request Feb 12, 2024
Description
-----------

Fixes #6862

Commits
-------

d65820d3 Correctly update the file name when synchronizing the DBAFS
57980108 Fix the unit test
4999037a Also update the file extension
a26ebdb9 Adjust the unit tests (see #11)

Co-authored-by: m-vo <m-vo@users.noreply.github.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