Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning: Invalid argument supplied for foreach() in system_get_date_formats() (line 3838 of system.module) #4690

Open
klonos opened this issue Oct 8, 2020 · 1 comment

Comments

@klonos
Copy link
Member

klonos commented Oct 8, 2020

This was reported by Dennis Tran in our Zulip chat, as an error thrown during updating a D7 Ubercart site to Backdrop:

Warning: Invalid argument supplied for foreach() in system_get_date_formats() (line 3838 of /var/www/backdrop.test/htdocs/core/modules/system/system.module).

The warning seems harmless, and the same user reported that it didn't seem to break anything, but we should nevertheless test the D7 to Backdrop upgrade, and make sure that date formats are being properly converted to config.

Some related issues: #530 #840 #974
...and a change record re the system_get_date_formats() function: https://api.backdropcms.org/change-records/systemgetdateformats-return-value-has-changed

@indigoxela
Copy link
Member

I suppose at that point of the upgrade no date formats have been set yet in system.date.json. It could possibly be a race condition, but that needs further digging.

This is the relevant code part.

    $date_formats = config_get('system.date', 'formats');
    foreach ($date_formats as $name => $format) {
      $date_formats[$name]['name'] = $name;
    }

If config_get() returned NULL, a loop will fail.

Additionally (unrelated here), the return value of function system_get_date_formats() is actually "mixed". If a requested format isn't found it returns FALSE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants