phpBB

Code Changes

File: phpbb/db/migration/data/v32x/merge_duplicate_bbcodes.php

  Unmodified   Added   Modified   Removed
Line 13Line 13

namespace phpbb\db\migration\data\v32x;



namespace phpbb\db\migration\data\v32x;


class merge_duplicate_bbcodes extends \phpbb\db\migration\migration

class merge_duplicate_bbcodes extends \phpbb\db\migration\container_aware_migration

{
public function update_data()
{

{
public function update_data()
{

Line 30Line 30
		while ($row = $this->db->sql_fetchrow($result))
{
$variant = (substr($row['bbcode_tag'], -1) === '=') ? 'with': 'without';

		while ($row = $this->db->sql_fetchrow($result))
{
$variant = (substr($row['bbcode_tag'], -1) === '=') ? 'with': 'without';

			$bbcode_name = rtrim($row['bbcode_tag'], '=');

			$bbcode_name = strtolower(rtrim($row['bbcode_tag'], '='));

			$bbcodes[$bbcode_name][$variant] = $row;
}
$this->db->sql_freeresult($result);

			$bbcodes[$bbcode_name][$variant] = $row;
}
$this->db->sql_freeresult($result);

Line 45Line 45
	}

protected function merge_bbcodes(array $without, array $with)

	}

protected function merge_bbcodes(array $without, array $with)

 
	{
try

	{
$merged = $this->container->get('text_formatter.s9e.bbcode_merger')->merge_bbcodes(
[

	{
$merged = $this->container->get('text_formatter.s9e.bbcode_merger')->merge_bbcodes(
[

Line 56Line 58
				'template' => $with['bbcode_tpl']
]
);

				'template' => $with['bbcode_tpl']
]
);

 
		}
catch (\Exception $e)
{
// Ignore the pair and move on. The BBCodes would have to be fixed manually
return;
}


		$bbcode_data = [
'bbcode_tag' => $without['bbcode_tag'],
'bbcode_helpline' => $without['bbcode_helpline'] . ' | ' . $with['bbcode_helpline'],

		$bbcode_data = [
'bbcode_tag' => $without['bbcode_tag'],
'bbcode_helpline' => $without['bbcode_helpline'] . ' | ' . $with['bbcode_helpline'],

Line 65Line 74

$sql = 'UPDATE ' . BBCODES_TABLE . '
SET ' . $this->db->sql_build_array('UPDATE', $bbcode_data) . '


$sql = 'UPDATE ' . BBCODES_TABLE . '
SET ' . $this->db->sql_build_array('UPDATE', $bbcode_data) . '

			WHERE bbcode_id = ' . $without['bbcode_id'];

			WHERE bbcode_id = ' . (int) $without['bbcode_id'];

		$this->sql_query($sql);

$sql = 'DELETE FROM ' . BBCODES_TABLE . '

		$this->sql_query($sql);

$sql = 'DELETE FROM ' . BBCODES_TABLE . '

			WHERE bbcode_id = ' . $with['bbcode_id'];

			WHERE bbcode_id = ' . (int) $with['bbcode_id'];

		$this->sql_query($sql);
}
}

		$this->sql_query($sql);
}
}