- Affected version
- XF2.3
If you create a code event listener for
Additionally the documentation should be updated to be explicit it is about nullable strings, ie:
This could be simplified to:
It is probably a good idea to not pass null into
bb_code_rules
, and give it a context hint; then the following will trigger it to be called when it is not expected:
Code:
{{ bb_code('test', null, null) }}
Additionally the documentation should be updated to be explicit it is about nullable strings, ie:
XML:
<em>\XF\BbCode\RuleSet</em> $ruleSet - The ruleset object being created.
<em>?string</em> $context - A string representing the context of the rule set, usually representing the content type.
<em>?string</em> $subContext - A string representing the sub-context of the rule set. This may not always be provided, but can represent a specific situation (such as "rss").
PHP:
$container->factory('rules', function($context, array $params, Container $c)
{
$parts = explode(':', $context, 2);
if (count($parts) == 2)
{
$context = $parts[0];
$subContext = $parts[1];
}
else
{
$subContext = null;
}
...
PHP:
$container->factory('rules', function($context, array $params, Container $c)
{
$parts = explode(':', $context ?? '', 2);
$context = $parts[0] ?? '';
$subContext = $parts[1] ?? null;
explode
as this triggers a warning from php 8.1+
Last edited: