Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
There is an error when saving an alert you scheduled by setting only date (without hour).
InvalidArgumentException: The date cannot be created from a format. in Drupal\Component\Datetime\DateTimePlus::createFromFormat() (line 248 of core/lib/Drupal/Component/Datetime/DateTimePlus.php).
This patch add validateForm function to make control on date fields.
Comment | File | Size | Author |
---|---|---|---|
#9 | sitewide_alert-error_when_saving_alert-3120815-9.patch | 957 bytes | nicolas.hod |
#6 | sitewide_alert-error_when_saving_alert-3120815-6.patch | 881 bytes | ChrisSnyder |
Comments
Comment #2
nicolas.hod CreditAttribution: nicolas.hod commentedComment #3
ChrisSnyderComment #4
nicolas.hod CreditAttribution: nicolas.hod commentedSorry, my test was inclompete ...
When posting form with good values, I get an other error with my patch.
Drupal\Core\Entity\EntityStorageException: Entity validation was skipped. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 846 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
Comment #5
ChrisSnyderComment #6
ChrisSnyderIt looks like the entity is trying create a date when no time is provided. The following patch should account for that.
Comment #7
ChrisSnyderComment #8
nicolas.hod CreditAttribution: nicolas.hod commentedYou're right. ;)
Just create a new patch by improving your test to prevent some warnings.
Thanks a lot.
Comment #9
nicolas.hod CreditAttribution: nicolas.hod commentedA fix to my previous patch...
Comment #10
Anonymous (not verified) CreditAttribution: Anonymous at Agiledrop - Your Trusted Drupal Teammates commentedHello,
I tested the patch #9 and it seems to work as expected. At first, I was getting
Warning: DateTime::createFromFormat() expects parameter 2 to be string, array given in Drupal\
error. But when I commented out the return on line 426 insrc/Entity/SitewideAlert.php
and refreshed the page everything was ok. When I removed the above comment everything was ok again and only received the errors The Start date date is invalid. I removed the module and cleared the cache and couldn't reproduce that warning again.Thanks for the contribution,
kind regards, Denis
Comment #11
ChrisSnyderThanks for the fix nicolas.hod and thanks for testing DenisCi!
Comment #13
ChrisSnyder