This commit is contained in:
rxu 2025-07-14 11:48:30 +07:00 committed by GitHub
commit a30f385fd1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 817 additions and 74 deletions

View file

@ -149,6 +149,7 @@ class connection_parameter_factory
$enrichment_tags = [
'pdo_mysql' => [
'charset' => 'UTF8',
'platform' => new mysql_platform(),
],
'oci8' => [
'charset' => 'UTF8',

View file

@ -0,0 +1,62 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
namespace phpbb\db\doctrine;
use Doctrine\DBAL\Platforms\AbstractMySQLPlatform;
use Doctrine\DBAL\Schema\TableDiff;
/**
* MySQL specific schema handling.
*
* While adding auto_increment column to MySQL, it must be indexed.
* If it's indexed as primary key, it should be declared as NOT NULL
* because MySQL primary key columns cannot be NULL.
*/
class mysql_platform extends AbstractMySQLPlatform
{
/**
* {@inheritDoc}
*/
public function getAlterTableSQL(TableDiff $diff)
{
$sql = parent::getAlterTableSQL($diff);
$table = $diff->getOldTable();
$columns = $diff->getAddedColumns();
foreach ($columns as $column)
{
$column_name = $column->getName();
if (!empty($column->getAutoincrement()) && $table)
{
foreach ($sql as $i => $query)
{
if (stripos($query, "add $column_name"))
{
if (!$table->getPrimaryKey())
{
$sql[$i] = str_replace(' DEFAULT NULL', '', $sql[$i]);
$sql[$i] .= ' PRIMARY KEY';
}
else
{
$sql[$i] .= ", ADD KEY ($column_name)";
}
}
}
}
}
return $sql;
}
}

View file

@ -14,10 +14,10 @@
namespace phpbb\db\doctrine;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use Doctrine\DBAL\Schema\Sequence;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\Types\BigIntType;
use Doctrine\DBAL\Types\IntegerType;
use Doctrine\DBAL\Types\SmallIntType;
@ -31,7 +31,7 @@ use Doctrine\DBAL\Types\Type;
* to stay compatible with the existing DB we have to change its
* naming and not ours.
*/
class postgresql_platform extends PostgreSQL94Platform
class postgresql_platform extends PostgreSQLPlatform
{
/**
* {@inheritdoc}
@ -78,6 +78,36 @@ class postgresql_platform extends PostgreSQL94Platform
return AbstractPlatform::getDefaultValueDeclarationSQL($column);
}
/**
* {@inheritDoc}
*/
public function getAlterTableSQL(TableDiff $diff)
{
$sql = parent::getAlterTableSQL($diff);
$table_name = $diff->getOldTable()->getName();
$columns = $diff->getAddedColumns();
$post_sql = $sequence_sql = [];
foreach ($columns as $column)
{
$column_name = $column->getName();
if (!empty($column->getAutoincrement()))
{
$sequence = new Sequence($this->getIdentitySequenceName($table_name, $column_name));
$sequence_sql[] = $this->getCreateSequenceSQL($sequence);
$post_sql[] = 'ALTER SEQUENCE ' . $sequence->getName() . ' OWNED BY ' . $table_name . '.' . $column_name;
}
}
$sql = array_merge($sequence_sql, $sql, $post_sql);
foreach ($sql as $i => $query)
{
$sql[$i] = str_replace('{{placeholder_sequence}}', "nextval('{$table_name}_seq')", $query);
}
return $sql;
}
/**
* {@inheritDoc}
*/
@ -157,31 +187,19 @@ class postgresql_platform extends PostgreSQL94Platform
{
// If we have a primary or a unique index, we need to drop the constraint
// instead of the index itself or postgreSQL will reject the query.
if ($index instanceof Index)
if (is_string($index) && $table !== null && $index === $this->tableName($table) . '_pkey')
{
if ($index->isPrimary())
{
if ($table instanceof Table)
{
$table = $table->getQuotedName($this);
}
else if (!is_string($table))
{
throw new \InvalidArgumentException(
__METHOD__ . '() expects $table parameter to be string or ' . Table::class . '.'
);
}
return 'ALTER TABLE '.$table.' DROP CONSTRAINT '.$index->getQuotedName($this);
}
}
else if (! is_string($index))
{
throw new \InvalidArgumentException(
__METHOD__ . '() expects $index parameter to be string or ' . Index::class . '.'
);
return $this->getDropConstraintSQL($index, $this->tableName($table));
}
return parent::getDropIndexSQL($index, $table);
}
/**
* {@inheritDoc}
*/
private function tableName($table)
{
return $table instanceof Table ? $table->getName() : (string) $table;
}
}

View file

@ -34,7 +34,15 @@ class remove_jabber extends migration
$this->table_prefix . 'users' => [
'user_jabber',
],
]
],
'add_columns' => [
$this->table_prefix . 'user_notifications' => [
'id' => ['ULINT', null, 'auto_increment'],
],
],
'add_primary_keys' => [
$this->table_prefix . 'user_notifications' => ['id'],
],
];
}
@ -45,7 +53,12 @@ class remove_jabber extends migration
$this->table_prefix . 'users' => [
'user_jabber' => ['VCHAR_UNI', ''],
],
]
],
'drop_columns' => [
$this->table_prefix . 'user_notifications' => [
'id',
],
],
];
}
@ -105,11 +118,22 @@ class remove_jabber extends migration
{
$limit = 1000;
$sql = 'UPDATE ' . $this->tables['user_notifications'] . '
SET ' . $this->db->sql_build_array('UPDATE', ['method' => 'notification.method.email']) . "
WHERE method = 'notification.method.jabber'";
$this->db->sql_query_limit($sql, $limit, $start ?: 0);
$sql = 'SELECT id FROM ' . $this->tables['user_notifications'] . "
WHERE method = 'notification.method.jabber'
ORDER BY id ASC";
$result = $this->db->sql_query_limit($sql, $limit, $start ?: 0);
$rowset = $this->db->sql_fetchrowset($result);
$this->db->sql_freeresult($result);
$ids_array = array_column($rowset, 'id');
return $this->db->sql_affectedrows() < $limit ? true : $start + $limit;
if (count($ids_array))
{
$sql = 'UPDATE ' . $this->tables['user_notifications'] . '
SET ' . $this->db->sql_build_array('UPDATE', ['method' => 'notification.method.email']) . '
WHERE ' . $this->db->sql_in_set('id', $ids_array);
$this->db->sql_query($sql);
}
return count($ids_array) < $limit ? true : $start + $limit;
}
}

View file

@ -185,6 +185,7 @@ class schema_generator
'drop_columns' => 'COLUMNS',
'change_columns' => 'COLUMNS',
'add_index' => 'KEYS',
'add_primary_keys' => 'PRIMARY_KEY',
'add_unique_index' => 'KEYS',
'drop_keys' => 'KEYS',
'rename_index' => 'KEYS',

View file

@ -377,7 +377,7 @@ class module implements \phpbb\db\migration\tool\tool_interface
{
if (!$this->exists($class, $parent, $module, true))
{
return;
throw new \phpbb\db\migration\exception('MODULE_NOT_EXIST', $module);
}
$parent_sql = '';

View file

@ -96,7 +96,7 @@ class doctrine implements tools_interface
*/
protected function get_schema(): Schema
{
return $this->get_schema_manager()->createSchema();
return $this->get_schema_manager()->introspectSchema();
}
/**
@ -300,36 +300,6 @@ class doctrine implements tools_interface
*/
public function sql_column_remove(string $table_name, string $column_name)
{
// Check if this column is part of a primary key. If yes, remove the primary key.
$primary_key_indexes = $this->get_filtered_index_list($table_name, false);
$primary_key_indexes = array_filter($primary_key_indexes, function($index) use ($column_name) {
$index_columns = array_map('strtolower', $index->getUnquotedColumns());
return in_array($column_name, $index_columns, true) && $index->isPrimary();
});
if (count($primary_key_indexes))
{
// For PostgreSQL, drop primary index first to avoid "Dependent objects still exist" error
if (stripos($this->get_schema_manager()->getDatabasePlatform()->getname(), 'postgresql') !== false)
{
$this->get_schema_manager()->dropIndex('"primary"', $table_name);
}
$ret = $this->alter_schema(
function (Schema $schema) use ($table_name, $column_name): void
{
$table = $schema->getTable($table_name);
$table->dropPrimaryKey();
}
);
if ($ret !== true)
{
return $ret;
}
}
return $this->alter_schema(
function (Schema $schema) use ($table_name, $column_name): void
{
@ -398,7 +368,7 @@ class doctrine implements tools_interface
return $this->alter_schema(
function (Schema $schema) use ($table_name, $column): void
{
$this->schema_create_primary_key($schema, $column, $table_name);
$this->schema_create_primary_key($schema, $table_name, $column);
}
);
}
@ -410,7 +380,7 @@ class doctrine implements tools_interface
{
try
{
$this->connection->executeQuery($this->get_schema_manager()->getDatabasePlatform()->getTruncateTableSQL($table_name));
$this->connection->executeQuery($this->connection->getDatabasePlatform()->getTruncateTableSQL($table_name));
}
catch (Exception $e)
{
@ -515,7 +485,7 @@ class doctrine implements tools_interface
$comparator = new comparator();
$schemaDiff = $comparator->compareSchemas($current_schema, $new_schema);
$queries = $schemaDiff->toSql($this->get_schema_manager()->getDatabasePlatform());
$queries = $schemaDiff->toSql($this->connection->getDatabasePlatform());
if ($this->return_statements)
{
@ -527,7 +497,6 @@ class doctrine implements tools_interface
// executeQuery() must be used here because $query might return a result set, for instance REPAIR does
$this->connection->executeQuery($query);
}
return true;
}
@ -659,7 +628,7 @@ class doctrine implements tools_interface
$table = $schema->createTable($table_name);
$short_table_name = table_helper::generate_shortname(self::remove_prefix($table_name, $this->table_prefix));
$dbms_name = $this->get_schema_manager()->getDatabasePlatform()->getName();
$dbms_name = $this->connection->getDatabasePlatform()->getName();
foreach ($table_data['COLUMNS'] as $column_name => $column_data)
{
@ -758,7 +727,7 @@ class doctrine implements tools_interface
return false;
}
$dbms_name = $this->get_schema_manager()->getDatabasePlatform()->getName();
$dbms_name = $this->connection->getDatabasePlatform()->getName();
list($type, $options) = table_helper::convert_column_data($column_data, $dbms_name);
$table->addColumn($column_name, $type, $options);
@ -790,7 +759,7 @@ class doctrine implements tools_interface
return;
}
$dbms_name = $this->get_schema_manager()->getDatabasePlatform()->getName();
$dbms_name = $this->connection->getDatabasePlatform()->getName();
list($type, $options) = table_helper::convert_column_data($column_data, $dbms_name);
$options['type'] = Type::getType($type);
@ -990,16 +959,16 @@ class doctrine implements tools_interface
/**
* Creates primary key for a table
*
* @param $column
* @param Schema $schema
* @param string $table_name
* @param array|string $column_name
* @param bool $safe_check
*
* @throws SchemaException
*/
protected function schema_create_primary_key(Schema $schema, $column, string $table_name, bool $safe_check = false): void
protected function schema_create_primary_key(Schema $schema, string $table_name, array|string $column_name, bool $safe_check = false): void
{
$columns = (is_array($column)) ? $column : [$column];
$columns = (is_array($column_name)) ? $column_name : [$column_name];
$table = $schema->getTable($table_name);
$table->dropPrimaryKey();
$table->setPrimaryKey($columns);

View file

@ -0,0 +1,43 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
class schema_add_autoincrement extends \phpbb\db\migration\migration
{
function update_schema()
{
return [
'add_tables' => [
$this->table_prefix . 'noid' => [
'COLUMNS' => [
'text' => ['VCHAR:50', ''],
],
],
],
'add_columns' => [
$this->table_prefix . 'noid' => [
'id' => ['UINT:3', null, 'auto_increment'],
],
],
];
}
function revert_schema()
{
return [
'drop_tables' => [
$this->table_prefix . 'noid',
],
];
}
}

View file

@ -25,6 +25,7 @@ require_once __DIR__ . '/migration/fail.php';
require_once __DIR__ . '/migration/installed.php';
require_once __DIR__ . '/migration/schema.php';
require_once __DIR__ . '/migration/schema_index.php';
require_once __DIR__ . '/migration/schema_add_autoincrement.php';
class phpbb_dbal_migrator_test extends phpbb_database_test_case
{
@ -502,4 +503,24 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case
}
}
}
public function test_add_autoincrement_column()
{
$this->migrator->set_migrations(['schema_add_autoincrement']);
while (!$this->migrator->finished())
{
$this->migrator->update();
}
$this->assertTrue($this->db_tools->sql_table_exists('phpbb_noid'));
$this->assertTrue($this->db_tools->sql_column_exists('phpbb_noid', 'id'));
while ($this->migrator->migration_state('schema_add_autoincrement'))
{
$this->migrator->revert('schema_add_autoincrement');
}
$this->assertFalse($this->db_tools->sql_table_exists('phpbb_noid'));
}
}

View file

@ -0,0 +1,284 @@
<?xml version="1.0" encoding="UTF-8" ?>
<dataset>
<table name="phpbb_migrations">
<column>migration_name</column>
<column>migration_depends_on</column>
<column>migration_schema_done</column>
<column>migration_data_done</column>
<column>migration_data_state</column>
<column>migration_start_time</column>
<column>migration_end_time</column>
</table>
<table name="phpbb_config">
<column>config_name</column>
<column>config_value</column>
<row>
<value>jab_enable</value>
<value>1</value>
</row>
<row>
<value>jab_host</value>
<value></value>
</row>
<row>
<value>jab_package_size</value>
<value>0</value>
</row>
<row>
<value>jab_password</value>
<value></value>
</row>
<row>
<value>jab_port</value>
<value></value>
</row>
<row>
<value>jab_use_ssl</value>
<value></value>
</row>
<row>
<value>jab_username</value>
<value>user</value>
</row>
<row>
<value>jab_verify_peer</value>
<value>0</value>
</row>
<row>
<value>jab_verify_peer_name</value>
<value>0</value>
</row>
<row>
<value>jab_allow_self_signed</value>
<value>0</value>
</row>
</table>
<table name="phpbb_modules">
<column>module_id</column>
<column>module_enabled</column>
<column>module_display</column>
<column>module_basename</column>
<column>module_class</column>
<column>parent_id</column>
<column>left_id</column>
<column>right_id</column>
<column>module_langname</column>
<column>module_mode</column>
<column>module_auth</column>
<row>
<value>1</value>
<value>1</value>
<value>1</value>
<value></value>
<value>acp</value>
<value>0</value>
<value>1</value>
<value>76</value>
<value>ACP_CAT_GENERAL</value>
<value></value>
<value></value>
</row>
<row>
<value>4</value>
<value>1</value>
<value>1</value>
<value></value>
<value>acp</value>
<value>1</value>
<value>48</value>
<value>59</value>
<value>ACP_CLIENT_COMMUNICATION</value>
<value></value>
<value></value>
</row>
<row>
<value>75</value>
<value>1</value>
<value>1</value>
<value>acp_jabber</value>
<value>acp</value>
<value>4</value>
<value>53</value>
<value>54</value>
<value>ACP_JABBER_SETTINGS</value>
<value>settings</value>
<value>acl_a_jabber</value>
</row>
</table>
<table name="phpbb_acl_options">
<column>auth_option_id</column>
<column>auth_option</column>
<column>is_global</column>
<column>is_local</column>
<column>founder_only</column>
<row>
<value>70</value>
<value>a_jabber</value>
<value>1</value>
<value>0</value>
<value>0</value>
</row>
<row>
<value>121</value>
<value>u_sendim</value>
<value>1</value>
<value>0</value>
<value>0</value>
</row>
</table>
<table name="phpbb_acl_groups">
<column>group_id</column>
<column>forum_id</column>
<column>auth_option_id</column>
<column>auth_role_id</column>
<column>auth_setting</column>
</table>
<table name="phpbb_acl_roles_data">
<column>role_id</column>
<column>auth_option_id</column>
<column>auth_setting</column>
<row>
<value>4</value>
<value>70</value>
<value>1</value>
</row>
<row>
<value>5</value>
<value>121</value>
<value>1</value>
</row>
<row>
<value>6</value>
<value>121</value>
<value>1</value>
</row>
</table>
<table name="phpbb_acl_users">
<column>user_id</column>
<column>forum_id</column>
<column>auth_option_id</column>
<column>auth_role_id</column>
<column>auth_setting</column>
</table>
<table name="phpbb_user_notifications">
<column>id</column>
<column>item_type</column>
<column>item_id</column>
<column>user_id</column>
<column>method</column>
<column>notify</column>
<row>
<value>1</value>
<value>notification.type.post</value>
<value>0</value>
<value>2</value>
<value>notification.method.jabber</value>
<value>1</value>
</row>
<row>
<value>2</value>
<value>notification.type.post</value>
<value>0</value>
<value>3</value>
<value>notification.method.jabber</value>
<value>1</value>
</row>
<row>
<value>3</value>
<value>notification.type.post</value>
<value>0</value>
<value>4</value>
<value>notification.method.jabber</value>
<value>1</value>
</row>
<row>
<value>4</value>
<value>notification.type.post</value>
<value>0</value>
<value>5</value>
<value>notification.method.jabber</value>
<value>1</value>
</row>
<row>
<value>5</value>
<value>notification.type.post</value>
<value>0</value>
<value>6</value>
<value>notification.method.jabber</value>
<value>1</value>
</row>
<row>
<value>6</value>
<value>notification.type.post</value>
<value>0</value>
<value>7</value>
<value>notification.method.jabber</value>
<value>1</value>
</row>
<row>
<value>7</value>
<value>notification.type.post</value>
<value>0</value>
<value>8</value>
<value>notification.method.jabber</value>
<value>1</value>
</row>
<row>
<value>8</value>
<value>notification.type.forum</value>
<value>0</value>
<value>2</value>
<value>notification.method.jabber</value>
<value>1</value>
</row>
<row>
<value>9</value>
<value>notification.type.forum</value>
<value>0</value>
<value>3</value>
<value>notification.method.jabber</value>
<value>1</value>
</row>
<row>
<value>10</value>
<value>notification.type.forum</value>
<value>0</value>
<value>4</value>
<value>notification.method.jabber</value>
<value>1</value>
</row>
<row>
<value>11</value>
<value>notification.type.forum</value>
<value>0</value>
<value>5</value>
<value>notification.method.jabber</value>
<value>1</value>
</row>
<row>
<value>12</value>
<value>notification.type.forum</value>
<value>0</value>
<value>6</value>
<value>notification.method.jabber</value>
<value>1</value>
</row>
<row>
<value>13</value>
<value>notification.type.forum</value>
<value>0</value>
<value>7</value>
<value>notification.method.jabber</value>
<value>1</value>
</row>
<row>
<value>14</value>
<value>notification.type.forum</value>
<value>0</value>
<value>8</value>
<value>notification.method.jabber</value>
<value>1</value>
</row>
</table>
</dataset>

View file

@ -0,0 +1,151 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
abstract class phpbb_migration_test_base extends phpbb_database_test_case
{
/** @var \phpbb\db\driver\driver_interface */
protected $db;
/** @var \Doctrine\DBAL\Connection */
protected $doctrine_db;
/** @var \phpbb\db\tools\tools_interface */
protected $db_tools;
/** @var \phpbb\db\migrator */
protected $migrator;
/** @var \phpbb\config\config */
protected $config;
/** @var \phpbb\extension\manager */
protected $extension_manager;
/** @var string */
protected $fixture;
/** @var string */
protected $migration_class;
public function getDataSet()
{
return $this->createXMLDataSet(__DIR__ . $this->fixture);
}
protected function setUp(): void
{
global $cache, $db, $phpbb_log, $phpbb_root_path, $phpEx, $skip_add_log, $table_prefix, $user;
parent::setUp();
// Disable the logs
$skip_add_log = true;
$db = $this->db = $this->new_dbal();
$this->doctrine_db = $this->new_doctrine_dbal();
$factory = new \phpbb\db\tools\factory();
$this->db_tools = $factory->get($this->doctrine_db);
$this->db_tools->set_table_prefix($table_prefix);
$this->cache = new phpbb_mock_cache();
$this->auth = new \phpbb\auth\auth();
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$this->config = new \phpbb\config\db($this->db, $this->cache, 'phpbb_config');
$this->config->initialise($this->cache);
$cache = $this->cache_service = new \phpbb\cache\service($this->cache, $this->config, $this->db, $phpbb_dispatcher, $phpbb_root_path, $phpEx);
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
$lang = new \phpbb\language\language($lang_loader);
$user = $this->user = new \phpbb\user($lang, '\phpbb\datetime');
$phpbb_log = new \phpbb\log\log($this->db, $this->user, $this->auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE);
$container = new phpbb_mock_container_builder();
$container->set('event_dispatcher', $phpbb_dispatcher);
$finder_factory = $this->createMock('\phpbb\finder\factory');
$this->extension_manager = new \phpbb\extension\manager(
$container,
$this->db,
$this->config,
$finder_factory,
'phpbb_ext',
__DIR__ . '/../../phpBB/',
null
);
$module_manager = new \phpbb\module\module_manager($this->cache, $this->db, $this->extension_manager, 'phpbb_modules', $phpbb_root_path, $phpEx);
$this->tools = array(
'config' => new \phpbb\db\migration\tool\config($this->config),
'config_text' => new \phpbb\db\migration\tool\config_text(new \phpbb\config\db_text($this->db, 'phpbb_config_text')),
'module' => new \phpbb\db\migration\tool\module($this->db, $this->user, $module_manager, 'phpbb_modules'),
'permission' => new \phpbb\db\migration\tool\permission($this->db, $this->cache_service, $this->auth, $phpbb_root_path, $phpEx),
);
$this->migrator = new \phpbb\db\migrator(
$container,
$this->config,
$this->db,
$this->db_tools,
'phpbb_migrations',
__DIR__ . '/../../phpBB/',
'php',
'phpbb_',
self::get_core_tables(),
$this->tools,
new \phpbb\db\migration\helper()
);
$container->set('migrator', $this->migrator);
$migration = $this->migrator->get_migration($this->migration_class);
$depends = $migration->depends_on();
$this->migrator->populate_migrations($depends);
$this->migrator->set_migrations([$this->migration_class]);
}
protected function apply_migration()
{
while (!$this->migrator->finished())
{
try
{
$this->migrator->update();
}
catch (\phpbb\db\migration\exception $e)
{
$this->fail('Applying migration error: ' . $e->__toString());
}
}
return $this->migrator->finished();
}
protected function revert_migration()
{
while ($this->migrator->migration_state($this->migration_class) !== false)
{
try
{
$this->migrator->revert($this->migration_class);
}
catch (\phpbb\db\migration\exception $e)
{
$this->fail('Reverting migration error: ' . $e->__toString());
}
}
return !$this->migrator->migration_state($this->migration_class);
}
}

View file

@ -0,0 +1,76 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
require_once __DIR__ . '/migration_test_base.php';
class phpbb_migrations_remove_jabber_migration_test extends phpbb_migration_test_base
{
protected $migration_class = '\phpbb\db\migration\data\v400\remove_jabber';
protected $fixture = '/fixtures/migration_remove_jabber.xml';
public function test_remove_jabber_migration()
{
$sql = "SELECT id FROM phpbb_user_notifications
WHERE method = 'notification.method.jabber'";
$result = $this->db->sql_query($sql);
$rowset = $this->db->sql_fetchrowset($result);
$this->db->sql_freeresult($result);
$this->assertEquals(14, count($rowset));
$sql = "SELECT config_name FROM phpbb_config
WHERE config_name = 'jab_enable'";
$this->assertNotFalse($this->db->sql_query($sql));
$this->assertTrue($this->tools['permission']->exists('a_jabber'));
$this->assertTrue($this->tools['permission']->exists('u_sendim'));
$this->assertTrue($this->tools['module']->exists('acp', 'ACP_CLIENT_COMMUNICATION', 'ACP_JABBER_SETTINGS'));
$this->apply_migration();
$sql = "SELECT id FROM phpbb_user_notifications
WHERE method = 'notification.method.jabber'";
$this->db->sql_query($sql);
$this->assertFalse($this->db->sql_fetchfield('id'));
$sql = "SELECT id FROM phpbb_user_notifications
WHERE method = 'notification.method.email'";
$result = $this->db->sql_query($sql);
$rowset = $this->db->sql_fetchrowset($result);
$this->db->sql_freeresult($result);
$this->assertEquals(14, count($rowset));
$sql = "SELECT config_name FROM phpbb_config
WHERE config_name = 'jab_enable'";
$this->db->sql_query($sql);
$this->assertFalse($this->db->sql_fetchfield('config_name'));
$this->assertFalse($this->tools['permission']->exists('a_jabber'));
$this->assertFalse($this->tools['permission']->exists('u_sendim'));
$this->assertFalse($this->tools['module']->exists('acp', 'ACP_CLIENT_COMMUNICATION', 'ACP_JABBER_SETTINGS'));
$this->revert_migration();
$sql = "SELECT config_name FROM phpbb_config
WHERE config_name = 'jab_enable'";
$this->db->sql_query($sql);
$this->assertEquals('jab_enable', $this->db->sql_fetchfield('config_name'));
$this->assertTrue($this->tools['permission']->exists('a_jabber'));
$this->assertTrue($this->tools['permission']->exists('u_sendim'));
$this->assertTrue($this->tools['module']->exists('acp', 'ACP_CLIENT_COMMUNICATION', 'ACP_JABBER_SETTINGS'));
// Apply migration back
$this->apply_migration();
}
}

View file

@ -164,12 +164,14 @@
</row>
</table>
<table name="phpbb_user_notifications">
<column>id</column>
<column>item_type</column>
<column>item_id</column>
<column>user_id</column>
<column>method</column>
<column>notify</column>
<row>
<value>1</value>
<value>notification.type.post</value>
<value>0</value>
<value>2</value>
@ -177,6 +179,7 @@
<value>1</value>
</row>
<row>
<value>2</value>
<value>notification.type.post</value>
<value>0</value>
<value>3</value>
@ -184,6 +187,7 @@
<value>1</value>
</row>
<row>
<value>3</value>
<value>notification.type.post</value>
<value>0</value>
<value>4</value>
@ -191,6 +195,7 @@
<value>1</value>
</row>
<row>
<value>4</value>
<value>notification.type.post</value>
<value>0</value>
<value>5</value>
@ -198,6 +203,7 @@
<value>1</value>
</row>
<row>
<value>5</value>
<value>notification.type.post</value>
<value>0</value>
<value>6</value>
@ -205,6 +211,7 @@
<value>1</value>
</row>
<row>
<value>6</value>
<value>notification.type.post</value>
<value>0</value>
<value>7</value>
@ -212,6 +219,7 @@
<value>1</value>
</row>
<row>
<value>7</value>
<value>notification.type.post</value>
<value>0</value>
<value>8</value>
@ -219,6 +227,7 @@
<value>1</value>
</row>
<row>
<value>8</value>
<value>notification.type.forum</value>
<value>0</value>
<value>2</value>
@ -226,6 +235,7 @@
<value>1</value>
</row>
<row>
<value>9</value>
<value>notification.type.forum</value>
<value>0</value>
<value>3</value>
@ -233,6 +243,7 @@
<value>1</value>
</row>
<row>
<value>10</value>
<value>notification.type.forum</value>
<value>0</value>
<value>4</value>
@ -240,6 +251,7 @@
<value>1</value>
</row>
<row>
<value>11</value>
<value>notification.type.forum</value>
<value>0</value>
<value>5</value>
@ -247,6 +259,7 @@
<value>1</value>
</row>
<row>
<value>12</value>
<value>notification.type.forum</value>
<value>0</value>
<value>6</value>
@ -254,6 +267,7 @@
<value>1</value>
</row>
<row>
<value>13</value>
<value>notification.type.forum</value>
<value>0</value>
<value>7</value>
@ -261,6 +275,7 @@
<value>1</value>
</row>
<row>
<value>14</value>
<value>notification.type.forum</value>
<value>0</value>
<value>8</value>

View file

@ -119,12 +119,14 @@
</row>
</table>
<table name="phpbb_user_notifications">
<column>id</column>
<column>item_type</column>
<column>item_id</column>
<column>user_id</column>
<column>method</column>
<column>notify</column>
<row>
<value>1</value>
<value>notification.type.bookmark</value>
<value>0</value>
<value>2</value>
@ -132,6 +134,7 @@
<value>1</value>
</row>
<row>
<value>2</value>
<value>notification.type.bookmark</value>
<value>0</value>
<value>3</value>
@ -139,6 +142,7 @@
<value>1</value>
</row>
<row>
<value>3</value>
<value>notification.type.bookmark</value>
<value>0</value>
<value>4</value>
@ -146,6 +150,7 @@
<value>1</value>
</row>
<row>
<value>4</value>
<value>notification.type.bookmark</value>
<value>0</value>
<value>5</value>
@ -153,6 +158,7 @@
<value>1</value>
</row>
<row>
<value>5</value>
<value>notification.type.bookmark</value>
<value>0</value>
<value>6</value>
@ -160,6 +166,7 @@
<value>0</value>
</row>
<row>
<value>6</value>
<value>notification.type.bookmark</value>
<value>0</value>
<value>3</value>

View file

@ -155,12 +155,14 @@
</row>
</table>
<table name="phpbb_user_notifications">
<column>id</column>
<column>item_type</column>
<column>item_id</column>
<column>user_id</column>
<column>method</column>
<column>notify</column>
<row>
<value>1</value>
<value>notification.type.post</value>
<value>0</value>
<value>2</value>
@ -168,6 +170,7 @@
<value>1</value>
</row>
<row>
<value>2</value>
<value>notification.type.post</value>
<value>0</value>
<value>3</value>
@ -175,6 +178,7 @@
<value>1</value>
</row>
<row>
<value>3</value>
<value>notification.type.post</value>
<value>0</value>
<value>4</value>
@ -182,6 +186,7 @@
<value>1</value>
</row>
<row>
<value>4</value>
<value>notification.type.post</value>
<value>0</value>
<value>5</value>
@ -189,6 +194,7 @@
<value>1</value>
</row>
<row>
<value>5</value>
<value>notification.type.post</value>
<value>0</value>
<value>6</value>
@ -196,6 +202,7 @@
<value>1</value>
</row>
<row>
<value>6</value>
<value>notification.type.post</value>
<value>0</value>
<value>7</value>
@ -203,6 +210,7 @@
<value>1</value>
</row>
<row>
<value>7</value>
<value>notification.type.post</value>
<value>0</value>
<value>8</value>
@ -210,6 +218,7 @@
<value>1</value>
</row>
<row>
<value>8</value>
<value>notification.type.forum</value>
<value>0</value>
<value>2</value>
@ -217,6 +226,7 @@
<value>1</value>
</row>
<row>
<value>9</value>
<value>notification.type.forum</value>
<value>0</value>
<value>3</value>
@ -224,6 +234,7 @@
<value>1</value>
</row>
<row>
<value>10</value>
<value>notification.type.forum</value>
<value>0</value>
<value>4</value>
@ -231,6 +242,7 @@
<value>1</value>
</row>
<row>
<value>11</value>
<value>notification.type.forum</value>
<value>0</value>
<value>5</value>
@ -238,6 +250,7 @@
<value>1</value>
</row>
<row>
<value>12</value>
<value>notification.type.forum</value>
<value>0</value>
<value>6</value>
@ -245,6 +258,7 @@
<value>1</value>
</row>
<row>
<value>13</value>
<value>notification.type.forum</value>
<value>0</value>
<value>7</value>
@ -252,6 +266,7 @@
<value>1</value>
</row>
<row>
<value>14</value>
<value>notification.type.forum</value>
<value>0</value>
<value>8</value>

View file

@ -136,12 +136,14 @@
</row>
</table>
<table name="phpbb_user_notifications">
<column>id</column>
<column>item_type</column>
<column>item_id</column>
<column>user_id</column>
<column>method</column>
<column>notify</column>
<row>
<value>1</value>
<value>notification.type.mention</value>
<value>0</value>
<value>2</value>
@ -149,6 +151,7 @@
<value>1</value>
</row>
<row>
<value>2</value>
<value>notification.type.mention</value>
<value>0</value>
<value>3</value>
@ -156,6 +159,7 @@
<value>1</value>
</row>
<row>
<value>3</value>
<value>notification.type.mention</value>
<value>0</value>
<value>4</value>
@ -163,6 +167,7 @@
<value>1</value>
</row>
<row>
<value>4</value>
<value>notification.type.mention</value>
<value>0</value>
<value>5</value>
@ -170,6 +175,7 @@
<value>1</value>
</row>
<row>
<value>5</value>
<value>notification.type.mention</value>
<value>0</value>
<value>6</value>
@ -177,6 +183,7 @@
<value>0</value>
</row>
<row>
<value>6</value>
<value>notification.type.mention</value>
<value>0</value>
<value>8</value>

View file

@ -155,12 +155,14 @@
</row>
</table>
<table name="phpbb_user_notifications">
<column>id</column>
<column>item_type</column>
<column>item_id</column>
<column>user_id</column>
<column>method</column>
<column>notify</column>
<row>
<value>1</value>
<value>notification.type.post</value>
<value>0</value>
<value>2</value>
@ -168,6 +170,7 @@
<value>1</value>
</row>
<row>
<value>2</value>
<value>notification.type.post</value>
<value>0</value>
<value>3</value>
@ -175,6 +178,7 @@
<value>1</value>
</row>
<row>
<value>3</value>
<value>notification.type.post</value>
<value>0</value>
<value>4</value>
@ -182,6 +186,7 @@
<value>1</value>
</row>
<row>
<value>4</value>
<value>notification.type.post</value>
<value>0</value>
<value>5</value>
@ -189,6 +194,7 @@
<value>1</value>
</row>
<row>
<value>5</value>
<value>notification.type.post</value>
<value>0</value>
<value>6</value>
@ -196,6 +202,7 @@
<value>1</value>
</row>
<row>
<value>6</value>
<value>notification.type.post</value>
<value>0</value>
<value>7</value>
@ -203,6 +210,7 @@
<value>1</value>
</row>
<row>
<value>7</value>
<value>notification.type.post</value>
<value>0</value>
<value>8</value>
@ -210,6 +218,7 @@
<value>1</value>
</row>
<row>
<value>8</value>
<value>notification.type.forum</value>
<value>0</value>
<value>2</value>
@ -217,6 +226,7 @@
<value>1</value>
</row>
<row>
<value>9</value>
<value>notification.type.forum</value>
<value>0</value>
<value>3</value>
@ -224,6 +234,7 @@
<value>1</value>
</row>
<row>
<value>10</value>
<value>notification.type.forum</value>
<value>0</value>
<value>4</value>
@ -231,6 +242,7 @@
<value>1</value>
</row>
<row>
<value>11</value>
<value>notification.type.forum</value>
<value>0</value>
<value>5</value>
@ -238,6 +250,7 @@
<value>1</value>
</row>
<row>
<value>12</value>
<value>notification.type.forum</value>
<value>0</value>
<value>6</value>
@ -245,6 +258,7 @@
<value>1</value>
</row>
<row>
<value>13</value>
<value>notification.type.forum</value>
<value>0</value>
<value>7</value>
@ -252,6 +266,7 @@
<value>1</value>
</row>
<row>
<value>14</value>
<value>notification.type.forum</value>
<value>0</value>
<value>8</value>

View file

@ -103,12 +103,14 @@
</row>
</table>
<table name="phpbb_user_notifications">
<column>id</column>
<column>item_type</column>
<column>item_id</column>
<column>user_id</column>
<column>method</column>
<column>notify</column>
<row>
<value>1</value>
<value>notification.type.needs_approval</value>
<value>0</value>
<value>2</value>
@ -116,6 +118,7 @@
<value>1</value>
</row>
<row>
<value>2</value>
<value>notification.type.needs_approval</value>
<value>0</value>
<value>3</value>
@ -123,6 +126,7 @@
<value>1</value>
</row>
<row>
<value>3</value>
<value>notification.type.needs_approval</value>
<value>0</value>
<value>4</value>
@ -130,6 +134,7 @@
<value>1</value>
</row>
<row>
<value>4</value>
<value>notification.type.needs_approval</value>
<value>0</value>
<value>5</value>
@ -137,6 +142,7 @@
<value>1</value>
</row>
<row>
<value>5</value>
<value>notification.type.needs_approval</value>
<value>0</value>
<value>6</value>
@ -144,6 +150,7 @@
<value>1</value>
</row>
<row>
<value>6</value>
<value>notification.type.needs_approval</value>
<value>0</value>
<value>7</value>
@ -151,6 +158,7 @@
<value>0</value>
</row>
<row>
<value>7</value>
<value>notification.type.needs_approval</value>
<value>0</value>
<value>9</value>

View file

@ -91,12 +91,14 @@
</row>
</table>
<table name="phpbb_user_notifications">
<column>id</column>
<column>item_type</column>
<column>item_id</column>
<column>user_id</column>
<column>method</column>
<column>notify</column>
<row>
<value>1</value>
<value>notification.type.quote</value>
<value>0</value>
<value>2</value>
@ -104,6 +106,7 @@
<value>1</value>
</row>
<row>
<value>2</value>
<value>notification.type.quote</value>
<value>0</value>
<value>3</value>
@ -111,6 +114,7 @@
<value>1</value>
</row>
<row>
<value>3</value>
<value>notification.type.quote</value>
<value>0</value>
<value>4</value>
@ -118,6 +122,7 @@
<value>1</value>
</row>
<row>
<value>4</value>
<value>notification.type.quote</value>
<value>0</value>
<value>5</value>
@ -125,6 +130,7 @@
<value>1</value>
</row>
<row>
<value>5</value>
<value>notification.type.quote</value>
<value>0</value>
<value>6</value>

View file

@ -99,12 +99,14 @@
</row>
</table>
<table name="phpbb_user_notifications">
<column>id</column>
<column>item_type</column>
<column>item_id</column>
<column>user_id</column>
<column>method</column>
<column>notify</column>
<row>
<value>1</value>
<value>notification.type.topic</value>
<value>0</value>
<value>2</value>
@ -112,6 +114,7 @@
<value>1</value>
</row>
<row>
<value>2</value>
<value>notification.type.topic</value>
<value>0</value>
<value>6</value>
@ -119,6 +122,7 @@
<value>1</value>
</row>
<row>
<value>3</value>
<value>notification.type.topic</value>
<value>0</value>
<value>7</value>
@ -126,6 +130,7 @@
<value>1</value>
</row>
<row>
<value>4</value>
<value>notification.type.topic</value>
<value>0</value>
<value>8</value>

View file

@ -185,12 +185,14 @@
</row>
</table>
<table name="phpbb_user_notifications">
<column>id</column>
<column>item_type</column>
<column>item_id</column>
<column>user_id</column>
<column>method</column>
<column>notify</column>
<row>
<value>1</value>
<value>notification.type.post</value>
<value>0</value>
<value>2</value>
@ -198,6 +200,7 @@
<value>1</value>
</row>
<row>
<value>2</value>
<value>notification.type.post</value>
<value>0</value>
<value>3</value>
@ -205,6 +208,7 @@
<value>1</value>
</row>
<row>
<value>3</value>
<value>notification.type.post</value>
<value>0</value>
<value>4</value>
@ -212,6 +216,7 @@
<value>1</value>
</row>
<row>
<value>4</value>
<value>notification.type.post</value>
<value>0</value>
<value>5</value>
@ -219,6 +224,7 @@
<value>1</value>
</row>
<row>
<value>5</value>
<value>notification.type.post</value>
<value>0</value>
<value>6</value>
@ -226,6 +232,7 @@
<value>1</value>
</row>
<row>
<value>6</value>
<value>notification.type.post</value>
<value>0</value>
<value>7</value>
@ -233,6 +240,7 @@
<value>1</value>
</row>
<row>
<value>7</value>
<value>notification.type.post</value>
<value>0</value>
<value>8</value>
@ -240,6 +248,7 @@
<value>1</value>
</row>
<row>
<value>8</value>
<value>notification.type.forum</value>
<value>0</value>
<value>2</value>
@ -247,6 +256,7 @@
<value>1</value>
</row>
<row>
<value>9</value>
<value>notification.type.forum</value>
<value>0</value>
<value>3</value>
@ -254,6 +264,7 @@
<value>1</value>
</row>
<row>
<value>10</value>
<value>notification.type.forum</value>
<value>0</value>
<value>4</value>
@ -261,6 +272,7 @@
<value>1</value>
</row>
<row>
<value>11</value>
<value>notification.type.forum</value>
<value>0</value>
<value>5</value>
@ -268,6 +280,7 @@
<value>1</value>
</row>
<row>
<value>12</value>
<value>notification.type.forum</value>
<value>0</value>
<value>6</value>
@ -275,6 +288,7 @@
<value>1</value>
</row>
<row>
<value>13</value>
<value>notification.type.forum</value>
<value>0</value>
<value>7</value>
@ -282,6 +296,7 @@
<value>1</value>
</row>
<row>
<value>14</value>
<value>notification.type.forum</value>
<value>0</value>
<value>8</value>