Fixed Import system doesn't proceed correctly for an importer with no base configuration

Jeremy P

XenForo developer
Staff member
Affected version
2.0.0
Judging from the import_config template, the import system is supposed to allow for importers that don't need any base configuration:

HTML:
<div class="block-body">
    <xf:if contentcheck="true">
        <xf:contentcheck>
            {{ $importer.renderBaseConfigOptions(vars())|raw }}
        </xf:contentcheck>
    <xf:else />
        <div class="block-row">{{ phrase('no_configuration_necessary') }}</div>
    </xf:if>
</div>

However, pressing continue on the respective page does not load the step configuration properly because it is dependent on the following condition in \XF\Admin\Controller\Import line 68:
PHP:
if ($baseConfig)
{
    ...
}

Since $baseConfig is an empty array, this line will always evaluate to false. The step importer does not have this problem, as the pertaining conditional instead checks for the presence of a hidden input (steps_configured on line 109).
 
Last edited:
I'm going to mark this as confirmed so it doesn't get lost, though the resolution may end up being that $baseConfig needs to be populated with something even if no actual configuration is required...

Will look into it.
 
Thank you. I think it could also be fixed by adding something like <xf:hiddenval name="configured">1</xf:hiddenval> to the import_config template and changing the conditional on \XF\Admin\Controller\Import line 68 to if ($this->filter('configured', 'bool')).

In the meantime it seems this can be worked around by adding a hidden config[] input to a template and setting renderBaseConfigOptions() to render it:
HTML:
<div class="block-row">{{ phrase('no_configuration_necessary') }}</div>

<xf:hiddenval name="config[]" />
 
This is fixed now. Two changes to make:
  1. As you suggested, add <xf:hiddenval name="config[]" /> to the import_config template, underneath the 'no_configuration_necessary' phrase
  2. In your config-free importer, just have validateBaseConfig() return true;
 
Top Bottom