Ive been using feeds to import users and discovered that the users timezone setting was not available.

Attached is a patch against 7.x-2.x-dev that adds a timezone target.

cheers
Louis

Comments

Louis Delacretaz created an issue. See original summary.

louis delacretaz’s picture

works well for me

megachriz’s picture

Status: Active » Needs review

Setting to "needs review" so the testbot will evaluate the patch.

Status: Needs review » Needs work

The last submitted patch, feeds_add-user-timezone_160123.patch, failed testing.

alan-ps’s picture

Status: Needs work » Needs review
StatusFileSize
new672 bytes

re-roll

megachriz’s picture

Status: Needs review » Needs work

I tried the patch and importing a timezone value worked when providing a valid timezone value.

  1. When providing an invalid timezone value (for example: "Europe/Rotterdam"), the value was imported as if it was a right value. I think Feeds should validate the incoming value by checking it against system_time_zones() and throw a FeedsValidationException if the value is invalid.
  2. It would be useful if the description of the target would display an example timezone value, so it is more clear what kind of value it expects. At first I wondered if I had to put in something like "+0200".
  3. An automated test for this feature would be nice. This would also remind me I would need to forward port the feature to D8 at some point.
alan-ps’s picture

Status: Needs work » Needs review
StatusFileSize
new4.29 KB

I think Feeds should validate the incoming value by checking it against system_time_zones() and throw a FeedsValidationException if the value is invalid.

Probably, we should just skip an import of the timezone (set to NULL) if value is incorrect. What do you think?

In any case, I have added necessary changes from the comment above for reviewing. Any remarks are welcome :)

megachriz’s picture

Thanks for your work, alan-ps!

I personally think that the item should be rejected, so the user is notified that the source contains a problem. In any case, emptying the current value in case of an invalid value doesn't sound right to me. Emptying should only be done if the provided value is empty. To test that behaviour, for one user there should be a timezone set before doing the import and for that same user there should be no timezone specified in the source file. After importing, the timezone should be empty.

There has been some discussion in #2379631: field_attach_validate() must be called before programmatic entity saves about whether or not an item should be "corrected" or rejected. My conclusion was that Feeds has no way of knowing if a value that is invalid is important or not. So it cannot decide if it is okay to just skip that value or if it should halt the whole item for it so the user can correct the source.

According to #2379631-11: field_attach_validate() must be called before programmatic entity saves there are three options:

  1. Skip the item. You're losing the user's data, which is bad.
  2. Import it anyway. This could cause warnings later.
  3. Reject it.
alan-ps’s picture

StatusFileSize
new4.21 KB
new2.99 KB

Yes, you convinced me! I have attached new patch with necessary changes.

megachriz’s picture

This looks great!

To make the tests complete, you could add the following:

  1. Give Fester a timezone before doing an import, so the test ensures that the import caused the timezone to be emptied. You'll need to set the processor to update existing users for this:
    // Set to update existing users.
    $this->setSettings('user_import', 'FeedsUserProcessor', array('update_existing' => FEEDS_UPDATE_EXISTING));
    
  2. Give Gomez an invalid timezone in the CSV file and assert that Gomez failed to import because of that (assert that user Gomez doesn't exist after import and that the expected error message is displayed).

As for the error message, maybe it should also display which value is invalid? It doesn't do for name and mail of the user though, but I think it could be helpful.

alan-ps’s picture

StatusFileSize
new4.99 KB
new2.77 KB

The patch was updated. I guess it will be final variant:)

megachriz’s picture

This looks good! I need some time yet to test it in action and if I found no issues I will commit it!

  • MegaChriz committed 44b9e9b on 7.x-2.x authored by alan-ps
    Issue #2655470 by alan-ps, Louis Delacretaz: Added a timezone target to...
megachriz’s picture

Status: Needs review » Fixed

Committed #11. Thanks!

Status: Fixed » Closed (fixed)

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