Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ services:
alias: text_formatter.s9e.renderer

phpbb\textformatter\cache_interface:
alias: text_formatter.s9e.factory
alias: text_formatter.cache

phpbb\textformatter\parser_interface:
alias: text_formatter.s9e.parser
Expand Down Expand Up @@ -76,6 +76,13 @@ services:
- '@service_container'
- '@config'

phpbb.pages.text_formatter.cache:
class: phpbb\pages\textformatter\cache
decorates: text_formatter.cache
arguments:
- '@phpbb.pages.text_formatter.cache.inner'
- '@phpbb.pages.text_formatter.factory'

phpbb.pages.text_formatter.factory:
class: phpbb\pages\textformatter\factory
arguments:
Expand Down
6 changes: 3 additions & 3 deletions entity/page_interface.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public function set_content($content);
/**
* Check if bbcode is enabled on the content
*
* @return bool
* @return int
* @access public
*/
public function content_bbcode_enabled();
Expand All @@ -253,7 +253,7 @@ public function content_disable_bbcode();
/**
* Check if magic_url is enabled on the content
*
* @return bool
* @return int
* @access public
*/
public function content_magic_url_enabled();
Expand All @@ -279,7 +279,7 @@ public function content_disable_magic_url();
/**
* Check if smilies are enabled on the content
*
* @return bool
* @return int
* @access public
*/
public function content_smilies_enabled();
Expand Down
36 changes: 36 additions & 0 deletions tests/textformatter/cache_test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/**
*
* Pages extension for the phpBB Forum Software package.
*
* @copyright (c) 2026 phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
*/

namespace phpbb\pages\tests\textformatter;

class cache_test extends \phpbb_test_case
{
public function test_invalidate_invalidates_core_and_pages_caches()
{
$core_cache = $this->createMock(\phpbb\textformatter\cache_interface::class);
$pages_cache = $this->createMock(\phpbb\textformatter\cache_interface::class);
$core_cache->expects(self::once())->method('invalidate');
$pages_cache->expects(self::once())->method('invalidate');

$cache = new \phpbb\pages\textformatter\cache($core_cache, $pages_cache);
$cache->invalidate();
}

public function test_tidy_tidies_core_and_regenerates_pages_cache()
{
$core_cache = $this->createMock(\phpbb\textformatter\cache_interface::class);
$pages_cache = $this->createMock(\phpbb\textformatter\cache_interface::class);
$core_cache->expects(self::once())->method('tidy');
$pages_cache->expects(self::once())->method('invalidate');

$cache = new \phpbb\pages\textformatter\cache($core_cache, $pages_cache);
$cache->tidy();
}
}
56 changes: 56 additions & 0 deletions textformatter/cache.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
/**
*
* Pages extension for the phpBB Forum Software package.
*
* @copyright (c) 2026 phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
*/

namespace phpbb\pages\textformatter;

/**
* Keeps the core and Pages text formatter caches synchronized
*/
class cache implements \phpbb\textformatter\cache_interface
{
/** @var \phpbb\textformatter\cache_interface */
protected $core_cache;

/** @var \phpbb\textformatter\cache_interface */
protected $pages_cache;

/**
* Constructor
*
* @param \phpbb\textformatter\cache_interface $core_cache Core text formatter cache
* @param \phpbb\textformatter\cache_interface $pages_cache Pages text formatter cache
*/
public function __construct(\phpbb\textformatter\cache_interface $core_cache, \phpbb\textformatter\cache_interface $pages_cache)
{
$this->core_cache = $core_cache;
$this->pages_cache = $pages_cache;
}

/**
* {@inheritdoc}
*/
public function invalidate()
{
$this->core_cache->invalidate();
$this->pages_cache->invalidate();
}

/**
* {@inheritdoc}
*/
public function tidy()
{
$this->core_cache->tidy();

// Core and Pages renderers share a directory. Core tidy removes the
// Pages renderer, so regenerate both Pages cache entries together.
$this->pages_cache->invalidate();
}
}