Problem/Motivation

I'm trying to update lots of incorrectly "0" dates (actually 1/1/1970) to be empty.
When I do this I get an error:

Error: Call to a member function setTimezone() on null in Drupal\bulk_update_fields\BulkUpdateFields::processDate() (line 17 of /opt/bitnami/apps/drupal/htdocs/modules/contrib/bulk_update_fields/src/BulkUpdateFields.php)

That makes sense, since setTimezone() can't handle empty values but this is a use case that should really be supported.

Steps to reproduce

1. Create a node with a value in a date field.
2. Use the module to try and clear out that date field's value.
3. See the error.

Proposed resolution

I'd recommend wrapping the date formatting logic in an if(empty($date)) statement.

I did this in my environment and it solved the problem. I'm not able to navigate the waters to update the underlying source here though.

CommentFileSizeAuthor
#2 3177195-1.patch710 bytesel1_1el

Comments

ekapus created an issue. See original summary.

el1_1el’s picture

Status: Active » Patch (to be ported)
StatusFileSize
new710 bytes

  • el1_1el authored f040e73 on 8.x-2.x
    Issue #3177195 by el1_1el, ekapus: Does not support emptying date fields
    
el1_1el’s picture

Status: Patch (to be ported) » Fixed

Status: Fixed » Closed (fixed)

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