mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
[ticket/12866] Update existing profile fields with the new validation
PHPBB3-12866
This commit is contained in:
parent
b7f69edaa2
commit
1145af71bf
1 changed files with 47 additions and 0 deletions
|
@ -0,0 +1,47 @@
|
||||||
|
<?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\migration\data\v31x;
|
||||||
|
|
||||||
|
class profilefield_remove_underscore_from_alpha extends \phpbb\db\migration\migration
|
||||||
|
{
|
||||||
|
static public function depends_on()
|
||||||
|
{
|
||||||
|
return array('\phpbb\db\migration\data\v31x\v311');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update_data()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
array('custom', array(array($this, 'remove_underscore_from_alpha_validations'))),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function remove_underscore_from_alpha_validations()
|
||||||
|
{
|
||||||
|
$this->update_validation_rule('[\w]+', '[a-zA-Z0-9]+');
|
||||||
|
$this->update_validation_rule('[\w_]+', '[\w]+');
|
||||||
|
$this->update_validation_rule('[\w.]+', '[a-zA-Z0-9.]+');
|
||||||
|
$this->update_validation_rule('[\w\x20_+\-\[\]]+', '[\w\x20+\-\[\]]+');
|
||||||
|
$this->update_validation_rule('[a-zA-Z][\w\.,\-_]+', '[a-zA-Z][\w\.,\-]+');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update_validation_rule($old_validation, $new_validation)
|
||||||
|
{
|
||||||
|
$sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . "
|
||||||
|
SET field_validation = '" . $this->db->sql_escpape($new_validation) . "'
|
||||||
|
WHERE field_validation = '" . $this->db->sql_escpape($old_validation) . "'";
|
||||||
|
$this->db->sql_query($sql);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue