PHPBB3-16169 - Add support for record filtering in text reparser

Discuss requests for comments/changes posted in the Issue Tracker for the development of phpBB. Upcoming release is 4.0/Triton.
Post Reply
User avatar
JoshyPHP
Registered User
Posts: 381
Joined: Fri Jul 08, 2011 9:43 pm

PHPBB3-16169 - Add support for record filtering in text reparser

Post by JoshyPHP »

https://tracker.phpbb.com/browse/
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
}
User avatar
3Di
Registered User
Posts: 884
Joined: Tue Nov 01, 2005 9:50 pm
Location: Milano 🇮🇹 Frankfurt 🇩🇪
Contact:

Re: PHPBB3-16169 - Add support for record filtering in text reparser

Post by 3Di »

Thanks for the news. 👍 Which will be available from phpBB4 as I can see.
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Want to compensate me for my interest? Donate
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
Post Reply