Problem/Motivation

When exporting new date formats with locale versions a bad format gets written in export file if those locale versions have not been explicitly saved.

This is the expected export file format:

$locale_date_formats['format_name::fi'] = array(
  'type' => 'format_name',
  'format' => 'j.n.Y - G:i',
  'locales' => array(
    0 => 'fi',
  ),
);

And here's the bad format:

$locale_date_formats['format_name::fi'] = array(
  'type' => 'format_name',
  'format' => array(
    'long' => 'l, j. F Y - G:i',
    'medium' => 'D j.n.Y',
    'short' => 'j.n.Y',
    'another_format_name' => 'j.n.Y - G:i',
  ),
  'locales' => array(
    0 => 'fi',
  ),
);

Proposed resolution

The problem is caused by _fe_date_get_locale_date_format not checking all possible return value formats from system_date_format_locale. A possible array of all date format strings for given locale is overlooked ending up in that array being written instead of an expected format string.

A proposed solution would be to add a check for an array type value in addition to current empty check.

Remaining tasks

  1. Code review & testing

Comments

tohesi created an issue. See original summary.

tohesi’s picture

Assigned: tohesi » Unassigned
Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new909 bytes

And here's my attempt for a fix.

wizonesolutions’s picture

Priority: Normal » Major
Issue tags: -date_format
StatusFileSize
new941 bytes

Rerolled against latest dev and based on the root directory of Features Extra (instead of the fe_date subdirectory.

Upping to major because this very easily breaks exported date formats in ways that are confusing to debug and understand.

@RenatoG at some point I should try to fix the tests to make them pass again. Then we could commit some of these patch fixes around dates like #2907422: Existing date formats not retrieved before inserting them