Quantcast
Channel: phpBB.com
Viewing all articles
Browse latest Browse all 38

Custom BBCode Development and Requests • The Extension I am developing stopped working after update to 3.3.11

$
0
0
I wrote a custom "hide" bbcode for my board to hide/show spoilers. It was working fine in 3.3.10, but after upgrading to 3.3.11, it causes this error:
[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)
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.
Here is my extension main_listener.php code:

Code:

<?phpnamespace medicinestorm\custombbcodes\event;use Symfony\Component\EventDispatcher\EventSubscriberInterface; class main_listener implements EventSubscriberInterface {# For including other functions.protected $db; // @var phpbb\db\driver\driver_interfacepublic 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 willtoggle only the first [hide] tag, regardless of which [hide]'s button was clicked. Setting the id valueto 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;}}
Am I missing some step? Should I now be (re)defining the bbcodes differently in the latest PHPBB version?

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:

<div style="margin-bottom: 1px;"><b style="font-size:120%;line-height:116%">{SIMPLETEXT} </b><input value="Show" class="button1"  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>
Help line:

Code:

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]

Statistics: Posted by MedicineStorm — Wed Feb 28, 2024 5:44 pm



Viewing all articles
Browse latest Browse all 38

Trending Articles