Fixed Bad example for icon_usage_analyzer_steps code event listener

Xon

Well-known member
Affected version
2.5.0Beta5
The example;
PHP:
public static function iconUsageAnalyzerSteps(
    array &$steps,
    \XF\Service\Icon\UsageAnalyzer $usageAnalyzer
): void
{
    $steps['my_content_type'] = [
        function (?int $lastOffset, float $maxRunTime) use ($usageAnalyzer): ?int
        {
            // your icon usage analyzer logic
            return null;
        },
    ];
}

This really should be;

PHP:
public static function iconUsageAnalyzerSteps(
    array &$steps,
    \XF\Service\Icon\UsageAnalyzer $usageAnalyzer
): void
{
    $steps['my_content_type'][] = function (?int $lastOffset, float $maxRunTime) use ($usageAnalyzer): ?int
        {
            // your icon usage analyzer logic
            return null;
        };
}

Appending to an array is much safer for compatibility than blindly setting it, especially if this is used to extend existing content types!
 
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.3.0 Beta 6).

Change log:
Improve code example for icon_usage_analyzer_steps code event.
There may be a delay before changes are rolled out to the XenForo Community.
 
Top Bottom