I'm guessing it's because of stricter methodologies in 3.3.11 and/or PHP 8.0+, but I'm not clear what I should be doing differently.angry phpbb 3.3.11 forum wrote:[28-Feb-2024 10:02:37 America/Boise] PHP Fatal error: Uncaught InvalidArgumentException: Filter array (
0 => 'medicinestorm\\custombbcodes\\event\\main_listener',
1 => 'process_tag_hide',
) is neither callable nor an instance of s9e\TextFormatter\Configurator\Items\TagFilter in /forum/vendor/s9e/text-formatter/src/Configurator/Collections/FilterChain.php:67
Stack trace:
#0 /forum/vendor/s9e/text-formatter/src/Configurator/Collections/NormalizedList.php(36): s9e\TextFormatter\Configurator\Collections\FilterChain->normalizeValue(Array)
#1 /forum/ext/medicinestorm/custombbcodes/event/main_listener.php(35): s9e\TextFormatter\Configurator\Collections\NormalizedList->append(Array)
Here is my extension main_listener.php code:
Code: Select all
<?php
namespace medicinestorm\custombbcodes\event;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class main_listener implements EventSubscriberInterface {
# For including other functions.
protected $db; // @var phpbb\db\driver\driver_interface
public function __construct(\phpbb\config\config $config
, \phpbb\controller\helper $helper
, \phpbb\template\template $template
, \phpbb\user $user
, \phpbb\db\driver\driver_interface $p_db) {
$this->config = $config;
$this->helper = $helper;
$this->template = $template;
$this->user = $user;
$this->db = $p_db;
}
public static function getSubscribedEvents() {
return [
'core.text_formatter_s9e_configure_after' => 'configure_bbcodes'
];
}
public function configure_bbcodes($event) {
# Get the BBCode configurator
$configurator = $event['configurator'];
# process special properties of [Hide] tag
$configurator->tags['hide']->filterChain
->append([__CLASS__, 'process_tag_hide']) /* LINE 35: THIS IS THE LINE WHERE THE STACK TRACE SAYS THE ERROR COMES FROM?? */
->addParameterByName('PARSERVAR.TAGCOUNT.HIDE')
->addParameterByName('PARSERVAR.PARSERINSTANCE')
->addParameterByName('PARSERVAR.USERID')
->addParameterByName('PARSERVAR.POSTID');
}
public function process_tag_hide(\s9e\TextFormatter\Parser\Tag $p_tag,
$p_intTagCountHide,
$p_intUserID,
$p_intPostID) {
/*
Without a unique identifier as the div's id value, clicking any "Hide"/"Show" button on the page will
toggle only the first [hide] tag, regardless of which [hide]'s button was clicked. Setting the id value
to a unique number ensures each [hide] button references only its own content.
The user id and the post id are added to help keep the identifier unique even if the tag count fails.
*/
//determine unique identifier
$strIdentifier = (string)$p_intUserID . '.' . (string)$p_intPostID . '.' . (string)$p_intTagCountHide;
//set the tag's parameter value(s)
$p_tag->setAttribute('bbcodehidetagid', $strIdentifier);
return true;
}
}
Just in case it makes a difference, here is the BBCode, as defined in my ACP > Posting > BBCodes:
Usage:
[hide={SIMPLETEXT;defaultValue=Click button to toggle hidden content}]{TEXT}[/hide]
HTML replacement:
Code: Select all
<div style="margin-bottom: 1px;">
<b style="font-size:120%;line-height:116%">{SIMPLETEXT} </b>
<input
value="Show"
class="button1"
onclick="const element=document.getElementById('bbcode-hide:{@bbcodehidetagid}');
if(element.style.display!='inline') {
element.style.display='inline';
this.innerText='';
this.value='Hide';
} else {
element.style.display='none';
this.innerText='';
this.value='Show';
}"
type="button">
</div>
<div style="border-style:solid;
border-width:2px;
border-top-color:#040;
border-left-color:#040;
border-right-color:#070;
border-bottom-color:#070;">
<div style="display:none;"
id="bbcode-hide:{@bbcodehidetagid}">
{TEXT}
</div>
</div>
Code: Select all
Hidden or "spoiler" text: [hide={optional title text}]{Text to be hidden}[/hide]
E.g.: [hide=Click to see Harry Potter spoilers]Snape kills Dumbledore![/hide]