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
CLI improvement before and during install #35011
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
a4edb59
Make Symfony CLI command more resilient to the absence of database or…
jolelievre 6c48053
Prevent locale twig extension from breaking the CLI by refactoring it…
jolelievre ae6bdc4
Prevent SqlTranslationLoader from breaking when DB is not initialized
jolelievre a5a04e6
Prevent warning during install when no shop URL is available yet
jolelievre 41f5267
Integrate more logs in the install process
jolelievre 12311e6
No HTTP redirection in CLI mode
jolelievre fc5ea0f
Db can not be created when configuration settings are not available
jolelievre ca2cdc4
Set some services use by Symfony command as lazy services to avoid cr…
jolelievre e6730eb
Remove parameter from service definition since it does not exist anymore
jolelievre e096348
Make config.inc.php and set_parameters.php more resilient when no con…
jolelievre fc39678
Add workflow to check that symfony console always works
jolelievre cf12cdd
Fix yaml and twig linter github actions
jolelievre 64fc8a8
Add custom DBAL connection wrapper class to prevent a bug in the CLI …
jolelievre File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: Symfony Console | ||
on: | ||
push: | ||
pull_request: | ||
|
||
permissions: | ||
contents: read | ||
concurrency: | ||
group: ${{ github.event_name }}-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
jobs: | ||
symfony-console: | ||
permissions: | ||
contents: read # for actions/checkout to fetch code | ||
name: Symfony Console | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: 8.1 | ||
extensions: mbstring, intl, gd, xml, dom, json, fileinfo, curl, zip, iconv | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Get Composer Cache Directory | ||
id: composer-cache | ||
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | ||
|
||
- name: Cache Composer Directory | ||
uses: actions/cache@v3 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: ${{ runner.os }}-composer- | ||
|
||
- name: Composer Install | ||
run: composer install --ansi --prefer-dist --no-interaction --no-progress | ||
|
||
- name: Check bin/console can run without shop install and cache clear | ||
run: | | ||
./bin/console | ||
./bin/console cache:clear --env=dev | ||
./bin/console cache:clear --env=prod | ||
./bin/console cache:clear --env=dev --no-warmup | ||
./bin/console cache:clear --env=prod --no-warmup | ||
|
||
# Now install the shop | ||
- name: Setup Environment | ||
timeout-minutes: 15 | ||
uses: ./.github/actions/setup-env | ||
with: | ||
PHP_VERSION: 8.1 | ||
ENABLE_SSL: 'true' | ||
INSTALL_AUTO: 'false' | ||
|
||
# Retest the console after shop install | ||
- name: Check bin/console and cache:clear can run after shop install | ||
run: | | ||
docker ps | ||
docker exec prestashop_prestashop-git_1 php ./bin/console | ||
docker exec prestashop_prestashop-git_1 php -d memory_limit=-1 ./bin/console cache:clear --env=dev | ||
docker exec prestashop_prestashop-git_1 php -d memory_limit=-1 ./bin/console cache:clear --env=prod | ||
docker exec prestashop_prestashop-git_1 php ./bin/console cache:clear --env=dev --no-warmup | ||
docker exec prestashop_prestashop-git_1 php ./bin/console cache:clear --env=prod --no-warmup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
/** | ||
* Copyright since 2007 PrestaShop SA and Contributors | ||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Open Software License (OSL 3.0) | ||
* that is bundled with this package in the file LICENSE.md. | ||
* It is also available through the world-wide-web at this URL: | ||
* https://opensource.org/licenses/OSL-3.0 | ||
* If you did not receive a copy of the license and are unable to | ||
* obtain it through the world-wide-web, please send an email | ||
* to license@prestashop.com so we can send you a copy immediately. | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer | ||
* versions in the future. If you wish to customize PrestaShop for your | ||
* needs please refer to https://devdocs.prestashop.com/ for more information. | ||
* | ||
* @author PrestaShop SA and Contributors <contact@prestashop.com> | ||
* @copyright Since 2007 PrestaShop SA and Contributors | ||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PrestaShopBundle\Doctrine; | ||
|
||
use Doctrine\DBAL\Connection; | ||
use Doctrine\DBAL\Driver\Exception; | ||
use Doctrine\DBAL\Platforms\MySQL57Platform; | ||
|
||
/** | ||
* This wrapper connection class is used to prevent a bug in CLI when the shop is not configured yet. | ||
* The problem is that Doctrine warm up automatically tries to get the database driver version vy connecting | ||
* to it, but when no configuration is set yet the connection obviously fails. | ||
* | ||
* There is a possible solution to force server_version in the doctrine DBAL configuration but since PrestaShop | ||
* is a framework that can be installed with different database versions we can't hard-code it, besides forcing | ||
* the version disables this automatic version detection feature. | ||
* | ||
* (See https://github.com/doctrine/DoctrineBundle/issues/673 for more details) | ||
* | ||
* So this class acts as a fallback when the connection tries to get the database platform but fails we catch the | ||
* exception, we check if the parameters file has been configured. If it doesn't exist then we are in a case where | ||
* the automatic detection failure can be ignored, in other case we throw the caught exception and change nothing to | ||
* the original behaviour thus reducing the impact of this wrapper as much as possible. | ||
* | ||
* In the case we handle a fallback we use MySQL 5.7 as the default platform. | ||
*/ | ||
class DatabaseConnection extends Connection | ||
{ | ||
private const PARAMETERS_FILE = __DIR__ . '/../../../app/config/parameters.php'; | ||
|
||
public function getDatabasePlatform() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Little unit test? |
||
{ | ||
try { | ||
$detectedVersion = parent::getDatabasePlatform(); | ||
} catch (Exception $e) { | ||
if (!file_exists(self::PARAMETERS_FILE)) { | ||
return new MySQL57Platform(); | ||
} | ||
|
||
throw $e; | ||
} | ||
|
||
return $detectedVersion; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: make it configurable with a construct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm gonna try but I'm not sure it's easily doable I wanted to do it at first but it implies modifying the constructor compared to the parent, and changing this constructor might mess with Doctrine initialization so I can't guarantee it will be doable