https://github.com/phpbb/phpbb/pull/5697
This PR adds the ability to specify new criteria to select what gets reparsed. For example, instead of reparsing everything, reparse only posts that contain the string
://
or match the regexp /youtube/i
. The main purpose is performance and efficiency, achieved by fetching fewer rows from the database and calling the message parser less. There is no implicit guarantee that only matching rows will be processed.A new method has been added to the reparser interface, the old one is soft-deprecated. The reparser manager's signature has been changed in a backward incompatible manner.
New CLI options
--filter-callback "my_callback"
(takes a record, returns a bool, exists mainly for completeness)--filter-text-like "<r%://%"
(SQL LIKE -- filters at the database level)--filter-text-regexp "/youtu.?be/i"
(PCRE -- filters in PHP)
Upgrade requirements
- Extensions that use
update_resume_data()
must be updated. (I don't think any exists.) - Extensions that require any of the removed methods must be updated. (I couldn't find any either.)
- Most extensions (such as the Pages extension) do not have to be updated because they only provide metadata for the
row_based_plugin
class.
Code: Select all
// Old
$manager->update_resume_data($name, $min, $current, $size);
// New
$data = [
'range-min' => $min,
'range-max' => $current,
'range-size' => $size
];
$manager->update_resume_data($name, $data);
Code: Select all
// Old
$reparser->reparse_range($name, $min, $max);
// New
$reparser->reparse($name, ['range-min' => $min, 'range-max' => $max]);
Code: Select all
namespace phpbb\textreparser;
interface reparser_interface
{
// Soft-deprecated (still functional but made redundant and should be removed)
public function reparse_range($min_id, $max_id);
// Added
public function reparse(array $config = []): void;
}
class manager
{
// Old
public function update_resume_data($name, $min, $current, $size, $update_db = true)
// New
public function update_resume_data(string $name, array $data, bool $update_db = true)
}
class base
{
// Removed
abstract protected function get_records_by_range($min_id, $max_id);
// Added
abstract protected function get_records(array $config): array;
}
class row_based_plugin
{
// Removed
protected function get_records_by_range_query($min_id, $max_id)
// Added
protected function get_records_sql(array $config): string
}