XF 2.3 Upgrade XFRM from XF1 to XF2 (Unknown widget 'xfrm_forum_overview_new_resources' )

nco

New member
Hello everybody !

We've just updated XF from version 1 to version 2.3. In version 1, we had the XFRM add-on (v1.2.4), which we're trying to update to version 2.3.4.
We get the following error (on-click upgrade or manually uploading the add-on)

InvalidArgumentException: Unknown widget 'xfrm_forum_overview_new_resources' src/addons/XFRM/Setup.php:1328
Looking at the add-on's code (Setup.php), the problem seems to be linked to the getDefaultWidgetSetup() method, which returns an array without a key named “xfrm_forum_overview_new_resources” (see the code below).

PHP:
        protected function getDefaultWidgetSetup()
        {
                return [
                        'xfrm_list_featured_resources' => function ($key, array $options = [])
                        {
                                $options = array_replace([
                                        'contextual' => true,
                                        'style' => 'carousel',
                                        'content_type' => 'resource',
                                ], $options);

                                $this->createWidget(
                                        $key,
                                        'featured_content',
                                        [
                                                'positions' => [
                                                        'xfrm_overview_above_resources' => 100,
                                                        'xfrm_category_above_resources' => 100,
                                                ],
                                                'options' => $options,
                                        ],
                                        'Featured resources'
                                );
                        },
                        'xfrm_list_top_resources' => function ($key, array $options = [])
                        {
                                $options = array_replace([], $options);

                                $this->createWidget(
                                        $key,
                                        'xfrm_top_resources',
                                        [
                                                'positions' => [
                                                        'xfrm_category_sidenav' => 100,
                                                        'xfrm_overview_sidenav' => 100,
                                                ],
                                                'options' => $options,
                                        ]
                                );
                        },
                        'xfrm_list_trending_resources' => function ($key, array $options = [])
                        {
                                $options = array_replace([
                                        'contextual' => true,
                                        'style' => 'simple',
                                        'content_type' => 'resource',
                                ], $options);

                                $this->createWidget(
                                        $key,
                                        'trending_content',
                                        [
                                                'positions' => [
                                                        'xfrm_category_sidenav' => 150,
                                                        'xfrm_overview_sidenav' => 150,
                                                ],
                                                'options' => $options,
                                        ],
                                        'Trending resources'
                                );
                        },
                        'xfrm_overview_latest_reviews' => function ($key, array $options = [])
                        {
                                $options = array_replace([], $options);

                                $this->createWidget(
                                        $key,
                                        'xfrm_latest_reviews',
                                        [
                                                'positions' => ['xfrm_overview_sidenav' => 200],
                                                'options' => $options,
                                        ]
                                );
                        },
                        'xfrm_overview_top_authors' => function ($key, array $options = [])
                        {
                                $options = array_replace([
                                        'member_stat_key' => 'xfrm_most_resources',
                                ], $options);

                                $this->createWidget(
                                        $key,
                                        'member_stat',
                                        [
                                                'positions' => ['xfrm_overview_sidenav' => 300],
                                                'options' => $options,
                                        ]
                                );
                        },
                        'xfrm_overview_statistics' => function ($key, array $options = [])
                        {
                                $options = array_replace([], $options);

                                $this->createWidget(
                                        $key,
                                        'xfrm_resource_statistics',
                                        [
                                                'positions' => ['xfrm_overview_sidenav' => 400],
                                                'options' => $options,
                                        ]
                                );
                        },
                        'xfrm_whats_new_overview_new_resources' => function ($key, array $options = [])
                        {
                                $options = array_replace([
                                        'limit' => 10,
                                        'style' => 'full',
                                ], $options);

                                $this->createWidget(
                                        $key,
                                        'xfrm_new_resources',
                                        [
                                                'positions' => ['whats_new_overview' => 200],
                                                'options' => $options,
                                        ]
                                );
                        },
                ];
        }

        protected function insertNamedWidget($key, array $options = [])
        {
                $widgets = $this->getDefaultWidgetSetup();
                if (!isset($widgets[$key]))
                {
                        throw new \InvalidArgumentException("Unknown widget '$key'");
                }

                $widgetFn = $widgets[$key];
                $widgetFn($key, $options);
        }

Do you have any suggestions to help me?

Thank you in advance.
 
Last edited:
We recommend upgrading directly instead of importing.

You can go to line 1328 of src/addons/XFRM/Setup.php and add return; above it, so it looks like this:
PHP:
    protected function insertNamedWidget($key, array $options = [])
    {
        $widgets = $this->getDefaultWidgetSetup();
        if (!isset($widgets[$key]))
        {
            return;
            throw new \InvalidArgumentException("Unknown widget '$key'");
        }

We'll have this fixed in the next release.
 
We recommend upgrading directly instead of importing.

You can go to line 1328 of src/addons/XFRM/Setup.php and add return; above it, so it looks like this:
PHP:
    protected function insertNamedWidget($key, array $options = [])
    {
        $widgets = $this->getDefaultWidgetSetup();
        if (!isset($widgets[$key]))
        {
            return;
            throw new \InvalidArgumentException("Unknown widget '$key'");
        }

We'll have this fixed in the next release.
Hello @Jeremy P,

That's what I did yesterday, and it worked! Thanks a lot!

What do you mean by "upgrading directly instead of importing" ? If you mean the admin panel, then we first tried this approach.
 
It was in reference to the post above, which suggested importing your existing forum into a new XenForo installation instead of upgrading.
 
  • Like
Reactions: nco
Back
Top Bottom