Drupal\Core\Database\Query\Insert::fields() must be of the type array, null given, called in modules/contrib/viewsreference/viewsreference.install on line 71 in Drupal\Core\Database\Query\Insert->fields()

In PHP7.1

CommentFileSizeAuthor
#4 2921423-3.patch1.89 KBrajab natshah

Comments

RajabNatshah created an issue. See original summary.

rajab natshah’s picture

Title: Error on Error on update TypeError: Argument 1 passed to Insert::fields() must be of the type array, null given, called in viewsreference.install on line 71 » Error on update TypeError: Argument 1 passed to Insert::fields() must be of the type array, null given, called in viewsreference.install on line 71
rajab natshah’s picture

Assigned: rajab natshah » Unassigned
Issue summary: View changes
Status: Needs work » Needs review
rajab natshah’s picture

StatusFileSize
new1.89 KB
rajab natshah’s picture

Status: Needs review » Needs work
rajab natshah’s picture

Status: Needs work » Needs review
seanb’s picture

The table fields array should never be null? Do you have a backup with a copy of your table structure from before the update? And did you have the 1.x version of the module installed before running the updates?

I think this patch hides an error that shouldn't happen, so I think it would be good to get to the bottom of this.

rajab natshah’s picture

Sean agree with you,

I'm doing this from an installation profile version to the next one, please do not worry about backups.
It's paragraphs field in a content type.

Having more troubleshooting over this patch.
Testing after the viewsreference 8.x-2.0-alpha3 release.

anybody’s picture

Status: Needs review » Reviewed & tested by the community

The patch works and is RTBC.
Hint: Using !empty() would have been a bit shorter but I think it's not worth to discuss that ;)
This happens if the update runs partially and some tables are already convertet.

seanb’s picture

#9 @Anybody, seems fair enough.

Small change to the patch, fixing this on commit.

+++ b/viewsreference.install
@@ -66,21 +66,28 @@ function viewsreference_update_8103() {
+        if (isset($table_fields)
+            && is_array($table_fields)
+            && count($table_fields) > 0) {

We could probably do a !empty($table_field) && is_array($table_fields). The empty check will take care of the isset and count > 0 at the same time.

  • seanB committed 40c27e0 on 8.x-2.x authored by RajabNatshah
    Issue #2921423 by RajabNatshah: Error on update TypeError: Argument 1...
seanb’s picture

Status: Reviewed & tested by the community » Fixed

Added to the latest dev. Please test it and let me know if there are any issues.

anybody’s picture

Perfect, thanks a lot to both of you :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.