-
Notifications
You must be signed in to change notification settings - Fork 68
MySQL fix timezone #1626
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
Merged
Merged
MySQL fix timezone #1626
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,45 @@ | ||
| {% extends 'admin/base_with_header.html.twig' %} | ||
|
|
||
| {% block content %} | ||
| <h1>Healthcheck</h1> | ||
| <div class="ui grid"> | ||
| <div class="eight wide column"> | ||
| <div class="ui segment"> | ||
| <h2 class="ui header">Dates</h2> | ||
| <div class="ui clearing divider"></div> | ||
| <dl> | ||
| <dt>PHP</dt> | ||
| <dd>{{ dates.php }}</dd> | ||
| <dt>MySQL Base_De_Donnees</dt> | ||
| <dd>{{ dates.mysql_bdd }}</dd> | ||
| <dt>MySQL Ting</dt> | ||
| <dd>{{ dates.mysql_ting }}</dd> | ||
| <dt>Différence MySQL et PHP</dt> | ||
| <dd> | ||
| {{ dates.diff ? 'Les timezones sont différentes' : 'Pas de différence de timezones' }} | ||
| </dd> | ||
| </dl> | ||
| </div> | ||
| </div> | ||
| <div class="eight wide column"> | ||
| <div class="ui segment"> | ||
| <h2 class="ui header">Versions</h2> | ||
| <div class="ui clearing divider"></div> | ||
| <dl> | ||
| <dt>PHP</dt> | ||
| <dd>{{ versions.php }}</dd> | ||
| <dt>Symfony</dt> | ||
| <dd>{{ versions.symfony }}</dd> | ||
| </dl> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| <style> | ||
| dt { | ||
| font-weight: bold; | ||
| } | ||
| dd { | ||
| font-family: "Noto Sans Mono", monospace; | ||
| } | ||
| </style> | ||
| {% endblock %} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
51 changes: 51 additions & 0 deletions
51
sources/AppBundle/Controller/Admin/HealthcheckController.php
This file contains hidden or 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,51 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace AppBundle\Controller\Admin; | ||
|
|
||
| use Afup\Site\Corporate\_Site_Base_De_Donnees; | ||
| use AppBundle\Event\Model\Repository\EventRepository; | ||
| use CCMBenchmark\TingBundle\Repository\RepositoryFactory; | ||
| use DateTime; | ||
| use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
| use Symfony\Component\HttpFoundation\Response; | ||
| use Symfony\Component\HttpKernel\Kernel; | ||
|
|
||
| class HealthcheckController extends AbstractController | ||
| { | ||
| private RepositoryFactory $ting; | ||
|
|
||
| public function __construct(RepositoryFactory $ting) | ||
| { | ||
| $this->ting = $ting; | ||
| } | ||
|
|
||
| public function __invoke(): Response | ||
| { | ||
| $php = new DateTime(); | ||
|
|
||
| $bdd = new _Site_Base_De_Donnees(); | ||
| $mysqlBdd = $bdd->obtenirUn('SELECT CURRENT_TIMESTAMP'); | ||
| $mysqlBdd = new DateTime($mysqlBdd); | ||
|
|
||
| $repo = $this->ting->get(EventRepository::class); | ||
| $mysqlTing = $repo->getQuery('SELECT CURRENT_TIMESTAMP')->execute()['CURRENT_TIMESTAMP']; | ||
| $mysqlTing = new DateTime($mysqlTing); | ||
|
|
||
| $diff = $php->getTimestamp() !== $mysqlBdd->getTimestamp() || $php->getTimestamp() !== $mysqlTing->getTimestamp(); | ||
|
|
||
| return $this->render('admin/healthcheck.html.twig', [ | ||
| 'dates' => [ | ||
| 'php' => $php->format(\DateTime::ATOM), | ||
| 'mysql_bdd' => $mysqlBdd->format(\DateTime::ATOM), | ||
| 'mysql_ting' => $mysqlTing->format(\DateTime::ATOM), | ||
| 'diff' => $diff | ||
| ], | ||
| 'versions' => [ | ||
| 'php' => phpversion(), | ||
| 'symfony' => Kernel::VERSION | ||
| ] | ||
| ]); | ||
| } | ||
| } | ||
This file contains hidden or 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,15 @@ | ||
| Feature: Administration - Healthcheck | ||
|
|
||
| @reloadDbWithTestData | ||
| Scenario: Un membre ne peut pas accéder aux vérifications du site | ||
| Given I am logged-in with the user "paul" and the password "paul" | ||
| And I am on "/admin/healthcheck" | ||
| Then the response status code should be 403 | ||
|
|
||
| @reloadDbWithTestData | ||
| Scenario: Vérifications du site | ||
| Given I am logged in as admin and on the Administration | ||
| And I follow "Healthcheck" | ||
| Then I should see "Healthcheck" | ||
| And I should see "Pas de différence de timezones" | ||
| And I should not see "Les timezones sont différentes" |
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.
Uh oh!
There was an error while loading. Please reload this page.