[ticket/13489] Update migrations

PHPBB3-13489
This commit is contained in:
Tristan Darricau 2015-01-14 12:07:53 +01:00
parent 4df125625c
commit ce47170c29
3 changed files with 57 additions and 20 deletions

View file

@ -13,8 +13,16 @@
namespace phpbb\db\migration\data\v30x;
class release_3_0_5_rc1 extends \phpbb\db\migration\migration
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class release_3_0_5_rc1 extends \phpbb\db\migration\migration implements ContainerAwareInterface
{
/**
* @var ContainerInterface
*/
protected $container;
public function effectively_installed()
{
return phpbb_version_compare($this->config['version'], '3.0.5-RC1', '>=');
@ -55,9 +63,7 @@ class release_3_0_5_rc1 extends \phpbb\db\migration\migration
public function hash_old_passwords()
{
global $phpbb_container;
$passwords_manager = $phpbb_container->get('passwords.manager');
$passwords_manager = $this->container->get('passwords.manager');
$sql = 'SELECT user_id, user_password
FROM ' . $this->table_prefix . 'users
WHERE user_pass_convert = 1';
@ -130,4 +136,12 @@ class release_3_0_5_rc1 extends \phpbb\db\migration\migration
}
}
}
/**
* {@inheritdoc}
*/
public function setContainer(ContainerInterface $container = null)
{
$this->container = $container;
}
}

View file

@ -13,13 +13,21 @@
namespace phpbb\db\migration\data\v310;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Migration to convert the Soft Delete MOD for 3.0
*
* https://www.phpbb.com/customise/db/mod/soft_delete/
*/
class soft_delete_mod_convert extends \phpbb\db\migration\migration
class soft_delete_mod_convert extends \phpbb\db\migration\migration implements ContainerAwareInterface
{
/**
* @var ContainerInterface
*/
protected $container;
static public function depends_on()
{
return array(
@ -115,19 +123,19 @@ class soft_delete_mod_convert extends \phpbb\db\migration\migration
}
}
/**
* @return \phpbb\content_visibility
*/
protected function get_content_visibility()
{
return new \phpbb\content_visibility(
new \phpbb\auth\auth(),
$this->config,
$this->db,
new \phpbb\user('\phpbb\datetime'),
$this->phpbb_root_path,
$this->php_ext,
$this->table_prefix . 'forums',
$this->table_prefix . 'posts',
$this->table_prefix . 'topics',
$this->table_prefix . 'users'
);
return $this->container->get('content.visibility');
}
/**
* {@inheritdoc}
*/
public function setContainer(ContainerInterface $container = null)
{
$this->container = $container;
}
}

View file

@ -13,7 +13,10 @@
namespace phpbb\db\migration;
abstract class profilefield_base_migration extends \phpbb\db\migration\migration
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
abstract class profilefield_base_migration extends \phpbb\db\migration\migration implements ContainerAwareInterface
{
protected $profilefield_name;
@ -40,6 +43,11 @@ abstract class profilefield_base_migration extends \phpbb\db\migration\migration
protected $user_column_name;
/**
* @var ContainerInterface
*/
protected $container;
public function effectively_installed()
{
return $this->db_tools->sql_column_exists($this->table_prefix . 'profile_fields_data', 'pf_' . $this->profilefield_name);
@ -237,11 +245,18 @@ abstract class profilefield_base_migration extends \phpbb\db\migration\migration
if ($profile_row === null)
{
global $phpbb_container;
$manager = $phpbb_container->get('profilefields.manager');
$manager = $this->container->get('profilefields.manager');
$profile_row = $manager->build_insert_sql_array(array());
}
return $profile_row;
}
/**
* {@inheritdoc}
*/
public function setContainer(ContainerInterface $container = null)
{
$this->container = $container;
}
}