statamic / v2-hub

Statamic 2 - Feature Requests and Bug Reports
https://statamic.com
95 stars 5 forks source link

BUG: Form submissions use commas instead of dots in filename #2428

Closed goldnead closed 3 years ago

goldnead commented 5 years ago

Describe the bug Related to: https://statamic.com/forum/3759-comma-in-filename-of-form-submission-after-switching-to-dutch-locale

Statamic saves form submissions into random numbered strings which get separated by a dot like site/storage/forms/contact/1565124392.8228.yaml. In my case (statamic v2.11.12) on german localization (de.UTF-8) the dot gets replaced by a comma which results in an error if statamic tries to fetch the submissions to display them in the backend (site/storage/forms/contact/1565124392,8228.yaml). I guess the reason for this behavior is that in germany decimals get separated by commas and not by dots like in the english language.

I digged a little deeper in the statamic codebase and found the issue: In file statamic/core/Forms/Submission.php at line 45 statamic uses the php-function microtime(true) enabling float numbers. That leads to different outputs depending on the localization of the current install.

A possible fix could be to just don't use floating numbers or to replace possible commas with a str_replace into dots.

EDIT: My hotfix was to replace the microtime commas with dots using: str_replace(',', '.', microtime(true)) since the pure microtime() returned s string including spaces.

To Reproduce Steps to reproduce the behavior:

  1. Install statamic
  2. Make sure you have an other language on your OS installed than english (in my example de_DE.UTF-8)
  3. Set the default language to that language in you `system.yaml'
  4. Set up example forms and hit submit
  5. Look at filenames of submitted Form 👀

Expected behavior Filenames should not containt any characters other than numbers and dots.

Environment details (please complete the following information):