-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #3135629 by alexpott, dww, daffie, jungle, Rkumar, balsama, xjm…
…, catch: Minimum MySQL version requirement is not confirmed when upgrading existing sites from Drupal 8 to Drupal 9
- Loading branch information
Showing
5 changed files
with
162 additions
and
1 deletion.
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
46 changes: 46 additions & 0 deletions
46
...s/modules/driver_test/src/Driver/Database/DrivertestMysqlDeprecatedVersion/Connection.php
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,46 @@ | ||
<?php | ||
|
||
namespace Drupal\driver_test\Driver\Database\DrivertestMysqlDeprecatedVersion; | ||
|
||
use Drupal\Core\Database\Driver\mysql\Connection as CoreConnection; | ||
|
||
/** | ||
* MySQL test implementation of \Drupal\Core\Database\Connection. | ||
*/ | ||
class Connection extends CoreConnection { | ||
|
||
/** | ||
* Constructs a Connection object. | ||
*/ | ||
public function __construct(\PDO $connection, array $connection_options = []) { | ||
// Alias the MySQL classes to avoid having unnecessary copies. | ||
foreach (['Delete', 'Insert', 'Merge', 'Schema', 'Upsert', 'Select', 'Update'] as $class) { | ||
class_alias('Drupal\\Core\\Database\\Driver\\mysql\\' . $class, 'Drupal\\driver_test\\Driver\\Database\\DrivertestMysqlDeprecatedVersion\\' . $class); | ||
} | ||
parent::__construct($connection, $connection_options); | ||
} | ||
|
||
/** | ||
* Hardcoded database server version. | ||
* | ||
* Faking that we are on a deprecated database. | ||
* | ||
* @var string | ||
*/ | ||
protected $databaseVersion = '5.5.2'; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function driver() { | ||
return 'DrivertestMysqlDeprecatedVersion'; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function version() { | ||
return $this->databaseVersion; | ||
} | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
...odules/driver_test/src/Driver/Database/DrivertestMysqlDeprecatedVersion/Install/Tasks.php
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,19 @@ | ||
<?php | ||
|
||
namespace Drupal\driver_test\Driver\Database\DrivertestMysqlDeprecatedVersion\Install; | ||
|
||
use Drupal\Core\Database\Driver\mysql\Install\Tasks as CoreTasks; | ||
|
||
/** | ||
* Specifies installation tasks for MySQL test databases. | ||
*/ | ||
class Tasks extends CoreTasks { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function name() { | ||
return t('MySQL deprecated version by the driver_test module'); | ||
} | ||
|
||
} |
68 changes: 68 additions & 0 deletions
68
modules/system/tests/src/Functional/Update/DatabaseVersionCheckUpdateTest.php
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,68 @@ | ||
<?php | ||
|
||
namespace Drupal\Tests\system\Functional\Update; | ||
|
||
use Drupal\Core\Database\Database; | ||
use Drupal\Core\Url; | ||
use Drupal\Tests\BrowserTestBase; | ||
use Drupal\Tests\UpdatePathTestTrait; | ||
|
||
/** | ||
* Tests that updates fail if the database does not meet the minimum version. | ||
* | ||
* @group Update | ||
*/ | ||
class DatabaseVersionCheckUpdateTest extends BrowserTestBase { | ||
use UpdatePathTestTrait; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected $defaultTheme = 'stark'; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function setUp(): void { | ||
parent::setUp(); | ||
$this->ensureUpdatesToRun(); | ||
} | ||
|
||
/** | ||
* Tests that updates fail if the database does not meet the minimum version. | ||
*/ | ||
public function testUpdate() { | ||
if (Database::getConnection()->driver() !== 'mysql') { | ||
$this->markTestSkipped('This test only works with the mysql driver'); | ||
} | ||
|
||
// Use a database driver that reports a fake database version that does | ||
// not meet requirements. Only change the necessary settings in the database | ||
// settings array so that run-tests.sh continues to work. | ||
$autoload = Database::findDriverAutoloadDirectory('Drupal\driver_test\Driver\Database\DrivertestMysqlDeprecatedVersion', \Drupal::root()); | ||
$settings['databases']['default']['default']['driver'] = (object) [ | ||
'value' => 'DrivertestMysqlDeprecatedVersion', | ||
'required' => TRUE, | ||
]; | ||
$settings['databases']['default']['default']['namespace'] = (object) [ | ||
'value' => 'Drupal\\driver_test\\Driver\\Database\\DrivertestMysqlDeprecatedVersion', | ||
'required' => TRUE, | ||
]; | ||
$settings['databases']['default']['default']['autoload'] = (object) [ | ||
'value' => $autoload, | ||
'required' => TRUE, | ||
]; | ||
$settings['settings'] = [ | ||
'update_free_access' => (object) [ | ||
'value' => TRUE, | ||
'required' => TRUE, | ||
], | ||
]; | ||
$this->writeSettings($settings); | ||
|
||
$this->drupalGet(Url::fromRoute('system.db_update')); | ||
$this->assertSession()->pageTextContains('Errors found'); | ||
$this->assertSession()->pageTextContains('The database server version 5.5.2 is less than the minimum required version'); | ||
} | ||
|
||
} |