Skip to content

Commit c3fcf79

Browse files
committed
Also don’t migrate/reparse if ideas bbcode isn’t found
1 parent f4853ce commit c3fcf79

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

migrations/m11_reparse_old_ideas.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function effectively_installed()
3434
/** @var \phpbb\textreparser\manager $reparser_manager */
3535
$reparser_manager = $this->container->get('text_reparser.manager');
3636

37-
return !empty($reparser_manager->get_resume_data('phpbb.ideas.text_reparser.clean_old_ideas'));
37+
return !empty($reparser_manager->get_resume_data('phpbb.ideas.text_reparser.clean_old_ideas') || !$this->bbcode_exists('idea'));
3838
}
3939

4040
/**
@@ -92,4 +92,23 @@ public function reparse($current = 0)
9292

9393
return $current;
9494
}
95+
96+
/**
97+
* Check if a bbcode exists
98+
*
99+
* @param string $tag BBCode's tag
100+
* @return bool True if bbcode exists, false if not
101+
*/
102+
public function bbcode_exists($tag)
103+
{
104+
$sql = 'SELECT bbcode_id
105+
FROM ' . $this->table_prefix . "bbcodes
106+
WHERE LOWER(bbcode_tag) = '" . $this->db->sql_escape(strtolower($tag)) . "'
107+
OR LOWER(bbcode_tag) = '" . $this->db->sql_escape(strtolower($tag)) . "='";
108+
$result = $this->db->sql_query_limit($sql, 1);
109+
$bbcode_id = $this->db->sql_fetchfield('bbcode_id');
110+
$this->db->sql_freeresult($result);
111+
112+
return $bbcode_id !== false;
113+
}
95114
}

0 commit comments

Comments
 (0)