Skip Navigation

[Resolved] PHP Fatal error: Uncaught TypeError: array_diff(): Argument #1 ($array) must be

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 8 replies, has 2 voices.

Last updated by Waqar 1 year, 10 months ago.

Assisted by: Waqar.

Author
Posts
#2506589

I am trying to:
Import data into custom posts (Konferensrum) from a very simple CSV-file using the WP All Import + the Toolset Types Addon Pro. I get an error and no posts are imported . Contacted Soflyy about it but they referred it to you, as a problem in Toolset. What's the cause of this problem?

Link to a page where the issue can be seen:
Backend in staging.konferensrumsdatabasen.se

I expected to see:
Two successfully imported Konferensrum posts (or at least a helpful error)

Instead, I got:
No posts are imported and no helpful errors to explain why. Checking logs it seems to be because of a fatal PHP error (below).

[28-Nov-2022 10:34:38 UTC] PHP Fatal error: Uncaught TypeError: array_diff(): Argument #1 ($array) must be of type array, int given in /var/www/vhosts/konferensrumsdatabasen.se/staging.konferensrumsdatabasen.se/wp-content/plugins/toolset-blocks/backend/Services/ViewParsingService.php:178
Stack trace:
#0 /var/www/vhosts/konferensrumsdatabasen.se/staging.konferensrumsdatabasen.se/wp-content/plugins/toolset-blocks/backend/Services/ViewParsingService.php(178): array_diff()
#1 /var/www/vhosts/konferensrumsdatabasen.se/staging.konferensrumsdatabasen.se/wp-includes/class-wp-hook.php(308): OTGS\Toolset\Views\Services\ViewParsingService->scan_for_view_block_usage()
#2 /var/www/vhosts/konferensrumsdatabasen.se/staging.konferensrumsdatabasen.se/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters()
#3 /var/www/vhosts/konferensrumsdatabasen.se/staging.konferensrumsdatabasen.se/wp-includes/plugin.php(517): WP_Hook->do_action()
#4 /var/www/vhosts/konferensrumsdatabasen.se/staging.konferensrumsdatabasen.se/wp-includes/post.php(4717): do_action()
#5 /var/www/vhosts/konferensrumsdatabasen.se/staging.konferensrumsdatabasen.se/wp-includes/post.php(4819): wp_insert_post()
#6 /var/www/vhosts/konferensrumsdatabasen.se/staging.konferensrumsdatabasen.se/wp-content/plugins/wp-all-import-pro/models/import/record.php(3023): wp_update_post()
#7 /var/www/vhosts/konferensrumsdatabasen.se/staging.konferensrumsdatabasen.se/wp-content/plugins/wp-all-import-pro/controllers/admin/import.php(2757): PMXI_Import_Record->process()
#8 /var/www/vhosts/konferensrumsdatabasen.se/staging.konferensrumsdatabasen.se/wp-content/plugins/wp-all-import-pro/wp-all-import-pro.php(761): PMXI_Admin_Import->process()
#9 /var/www/vhosts/konferensrumsdatabasen.se/staging.konferensrumsdatabasen.se/wp-includes/class-wp-hook.php(308): PMXI_Plugin->adminInit()
#10 /var/www/vhosts/konferensrumsdatabasen.se/staging.konferensrumsdatabasen.se/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters()
#11 /var/www/vhosts/konferensrumsdatabasen.se/staging.konferensrumsdatabasen.se/wp-includes/plugin.php(517): WP_Hook->do_action()
#12 /var/www/vhosts/konferensrumsdatabasen.se/staging.konferensrumsdatabasen.se/wp-admin/admin.php(175): do_action()
#13 {main}
thrown in /var/www/vhosts/konferensrumsdatabasen.se/staging.konferensrumsdatabasen.se/wp-content/plugins/toolset-blocks/backend/Services/ViewParsingService.php on line 178

#2507313

Hi,

Thank you for contacting us and I'd be happy to assist.

From the error messages, it is not clear how and why that particular part of the code is getting involved during the import process.

To troubleshoot this, I'll need to know the exact steps that you followed for the import. Can you please share those along with the example import file that you used?

I'll also need your permission to download a clone/snapshot of the website, in case it needs to be investigated on a different server.

regards,
Waqar

#2507471

Hi Waqar,
These are the steps I follow to import:
1. Choose "Manage Imports" from the "All Import" menu in the WP back-end.
2. Click the "Run Import" button on the first alternative (importing into konferensrum).
3. Confirm with the green button.

As you can see on the page in step 2, the csv-files are already on the server.

Btw. the reason I have two imports is because I don't know a way of how to make an import where I combine two related custom post types. So my solution was to first run an import of rooms (konferensrum) and then run another import with equipment for these imported rooms (rumstrustning). Would be great if this could be combined to one import...

#2507473

And yes, you're free to make a mirro copy of the site as longs as it's destroyed when we're finished.

#2510267

Thank you for sharing these details and for the permission.

I've downloaded the website's clone and will be performing some tests on this.

Will share the findings, as soon as this testing completes. Thank you for your patience.

#2513845

Any insights yet?

#2515101

Thank you for waiting as we had some unusually busy forum queue after the weekend.

I've tested the import process on your website's clone, on a couple of different servers and couldn't reproduce the error you reported.

Here are the steps, that I followed for these tests.

1. I used the import file named "Excelimport1.csv" from your website, which had two rows/records.

2. I didn't know the exact mapping of which columns you linked with different fields, so I just used the {ortnamnomfinnsmstevaraexaktanamnet[1]} column for the post title and the {rumsbeskrivninglng[1]} column for the post content.
( screenshot: hidden link )

3. The import process was completed each time successfully without any errors or warnings. It also showed the message that one new Konferensrum post was created and one was updated.
( one of them must have been added during your previous tests )

I'll recommend testing the import process again and capturing a screencast/video of the steps that you're using (especially for the column mapping for the fields in the post).

As for the post relationships, you can import them through the same CSV file, without having to divide the import process into two steps/files. You can include the post title of the related post(s) in one of the columns in the CSV file, as explained in this guide:
https://toolset.com/course-lesson/import-posts-from-csv-with-relationships-using-wp-all-import/

#2516169

Thanks for your answer! Seems to be some hope, however, I still can't import a single post. I've removed ALL the Toolset Types Add-On fields (rumfält) from the import template but it doesn't change anything here on my staging server.
So even with a very simple template the import just stops ("terminated by server"). No logs in WP import but the debug log shows one fatal error (Uncaught TypeError: array_diff()). See detail and stack trace below.

So the ONLY fields I use are the name ({rumnamn[1]}) and the description (as you guessed) fields now.
But if you managed to import Konferensrum on your mirror site, could it be anything with the server or PHP-version etc.?

From debug.log:

15-Dec-2022 10:12:30 UTC] PHP Fatal error: Uncaught TypeError: array_diff(): Argument #1 ($array) must be of type array, int given in /var/www/vhosts/konferensrumsdatabasen.se/staging.konferensrumsdatabasen.se/wp-content/plugins/toolset-blocks/backend/Services/ViewParsingService.php:178

Stack trace:
#0 /var/www/vhosts/konferensrumsdatabasen.se/staging.konferensrumsdatabasen.se/wp-content/plugins/toolset-blocks/backend/Services/ViewParsingService.php(178): array_diff()
#1 /var/www/vhosts/konferensrumsdatabasen.se/staging.konferensrumsdatabasen.se/wp-includes/class-wp-hook.php(308): OTGS\Toolset\Views\Services\ViewParsingService->scan_for_view_block_usage()
#2 /var/www/vhosts/konferensrumsdatabasen.se/staging.konferensrumsdatabasen.se/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters()
#3 /var/www/vhosts/konferensrumsdatabasen.se/staging.konferensrumsdatabasen.se/wp-includes/plugin.php(517): WP_Hook->do_action()
#4 /var/www/vhosts/konferensrumsdatabasen.se/staging.konferensrumsdatabasen.se/wp-includes/post.php(4717): do_action()
#5 /var/www/vhosts/konferensrumsdatabasen.se/staging.konferensrumsdatabasen.se/wp-includes/post.php(4819): wp_insert_post()
#6 /var/www/vhosts/konferensrumsdatabasen.se/staging.konferensrumsdatabasen.se/wp-content/plugins/wp-all-import-pro/models/import/record.php(3023): wp_update_post()
#7 /var/www/vhosts/konferensrumsdatabasen.se/staging.konferensrumsdatabasen.se/wp-content/plugins/wp-all-import-pro/controllers/admin/import.php(2757): PMXI_Import_Record->process()
#8 /var/www/vhosts/konferensrumsdatabasen.se/staging.konferensrumsdatabasen.se/wp-content/plugins/wp-all-import-pro/wp-all-import-pro.php(761): PMXI_Admin_Import->process()
#9 /var/www/vhosts/konferensrumsdatabasen.se/staging.konferensrumsdatabasen.se/wp-includes/class-wp-hook.php(308): PMXI_Plugin->adminInit()
#10 /var/www/vhosts/konferensrumsdatabasen.se/staging.konferensrumsdatabasen.se/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters()
#11 /var/www/vhosts/konferensrumsdatabasen.se/staging.konferensrumsdatabasen.se/wp-includes/plugin.php(517): WP_Hook->do_action()
#12 /var/www/vhosts/konferensrumsdatabasen.se/staging.konferensrumsdatabasen.se/wp-admin/admin.php(175): do_action()
#13 {main}
thrown in /var/www/vhosts/konferensrumsdatabasen.se/staging.konferensrumsdatabasen.se/wp-content/plugins/toolset-blocks/backend/Services/ViewParsingService.php on line 178

#2525675

Thank you for waiting, as we were a little light on the forum coverage due to the holidays.

During troubleshooting, I found an unusual custom field/meta entry, which would explain this error on your website.

Toolset stores the ID of a blocks-based view used on a post/page, in a hidden custom field key '_wpv_contains_gutenberg_views', in an array (square bracket [123]) format.

But, for one of the 'Konferensrum' posts ( 'ID4412 – Hunden' ), the ID '1649' of the view 'KundView' is saved without the square brackets.
( screenshot: hidden link )

Using a database editing tool like phpMyAdmin, you can navigate to that custom field/post meta record in the "{table_prefix}_postmeta" table and change the value from '1649' to '[1649]'.

Here is how the query will look like, to navigate to that record:


SELECT * FROM `GQ3TmdJq6_postmeta` WHERE meta_key='_wpv_contains_gutenberg_views' AND meta_value='1649';

Note: Please change the "GQ3TmdJq6" part based on the {table_prefix} set for your website.

After making this change, test the import process again and it should complete without the error.