XF 2.0 An exception occurred: [TypeError] Argument 2 passed to XF\App::getCustomFieldsForEdit()

Here's a quick recap:

Wanted to migrate from a Joomla (CMS) Kunena forum to XF.

No importers exist, so I opted for migrating to WordPress's BBPress forum software, and then on to XF from there.

Used this BBpress importer (https://xenforo.com/community/resources/bbpress-importer.5474/) to migrate to XF.

Ported over to an empty XF 1.5 installation. I rebuilt threads, forums and user caches as instructed. Everything worked.

From there, I upgraded to XF 2 (latest version) following all the instructions. Again, successfully.

My problem is now, that when clicking on users (on any user), I get the following error:

Code:
An exception occurred: [TypeError] Argument 2 passed to XF\App::getCustomFieldsForEdit() must be an instance of XF\CustomField\Set, null given in src/XF/App.php on line 1581

XF\App->getCustomFieldsForEdit()
call_user_func_array() in src/XF/Template/Templater.php at line 936
XF\Template\Templater->method() in internal_data/code_cache/templates/l3/s0/public/custom_fields_macros.php at line 174
XF\Template\Templater->{closure}() in src/XF/Template/Templater.php at line 659
XF\Template\Templater->callMacro() in internal_data/code_cache/templates/l3/s0/admin/user_edit.php at line 552
XF\Template\Templater->{closure}() in src/XF/Template/Templater.php at line 1246
XF\Template\Templater->renderTemplate() in src/XF/Template/Template.php at line 24
XF\Template\Template->render() in src/XF/Mvc/Renderer/Html.php at line 48
XF\Mvc\Renderer\Html->renderView() in src/XF/Mvc/Dispatcher.php at line 332
XF\Mvc\Dispatcher->renderView() in src/XF/Mvc/Dispatcher.php at line 303
XF\Mvc\Dispatcher->render() in src/XF/Mvc/Dispatcher.php at line 44
XF\Mvc\Dispatcher->run() in src/XF/App.php at line 1889
XF\App->run() in src/XF.php at line 328
XF::runApp() in admin.php at line 13

I've tried a file health check, and everything is good.

Creating new users (for instance my admin profile) results in a fully working and viewable user-profile.

I've looked at the referenced App.php line, but nothing stands out to me.

Can anyone please assist? Would greatly appreciate it.
 
I suspect this might be down to the import itself perhaps not creating records in the xf_user_profile table for some (or maybe all) users. Are you able to confirm if that is the case?
 
I've confirmed by looking at the code that the importer does not create the expected records for all users. This is a fairly big problem and will cause the sorts of issue you described.

As a quick fix, this will create blank records for each user in each table where applicable:
SQL:
INSERT IGNORE INTO xf_user_option (user_id) SELECT user_id FROM xf_user;
INSERT IGNORE INTO xf_user_privacy (user_id) SELECT user_id FROM xf_user;
INSERT IGNORE INTO xf_user_profile (user_id) SELECT user_id FROM xf_user;
INSERT IGNORE INTO xf_user_authenticate (user_id) SELECT user_id FROM xf_user;
 
I suspect this might be down to the import itself perhaps not creating records in the xf_user_profile table for some (or maybe all) users. Are you able to confirm if that is the case?
You know, I saw this the other day when you posted. I was about to try and figure out how to confirm the missing records, but got slightly overwhelmed and left it.

-come back to:

I've confirmed by looking at the code that the importer does not create the expected records for all users. This is a fairly big problem and will cause the sorts of issue you described.

As a quick fix, this will create blank records for each user in each table where applicable:
SQL:
INSERT IGNORE INTO xf_user_option (user_id) SELECT user_id FROM xf_user;
INSERT IGNORE INTO xf_user_privacy (user_id) SELECT user_id FROM xf_user;
INSERT IGNORE INTO xf_user_profile (user_id) SELECT user_id FROM xf_user;
INSERT IGNORE INTO xf_user_authenticate (user_id) SELECT user_id FROM xf_user;

-and that's absolutely brilliant. It worked, and now I was also able to rebuild users like it kept asking me for after I had upgraded to version 2.X (even though I had already done this in the earlier version).

So thank you very much Chris -- it looks to be working now.
 
I ran these queries, and only the third one produced a result (four rows inserted). 1,2and4 did nothing.

However, I'm running the latest version. Would that make a difference?
 
Top Bottom