Problem/Motivation

Dates are being mangled by the PHP-intl module

Proposed resolution

Not sure -- symfony needs the php-intl module, but there's definitely problems here

Remaining tasks

Patch needed

User interface changes

None

API changes

None that I know of

http://drupal.org/node/1944636

Steps to reproduce:

* Check out a fresh Drupal 8 install via git
* Make sure the PHP "intl" module is installed on the web server (and that the web server was restarted)
* Create a new "Basic Page" node
* Click on the "Edit" tab
* Click on the "Authoring Information" accordian tab
* Notice that the date is set as "131313-MayMay-2121" and that the time is similarly garbled.
* Disable the php-intl module
* Restart the web server
* Notice that when you edit the node, the authoring information is normal

Note that this issue looks very similar to http://drupal.org/node/1944636, which was supposed to solve this a similar issue, but apparently doesn't fix this particular case.

Also note that I've tested this across several different browsers, and even gone so far as to fire up a packet sniffer to show that bad data really is coming from the web server.

Files: 
CommentFileSizeAuthor
#62 60-62-interdiff.txt1.36 KBalexpott
#62 resolving-pb-with-date-format-output_and_validation-2000384-62.patch11.24 KBalexpott
PASSED: [[SimpleTest]]: [MySQL] 58,920 pass(es).
[ View ]
#60 resolving-pb-with-date-format-output_and_validation-2000384-60.patch10.58 KByuradoc
PASSED: [[SimpleTest]]: [MySQL] 59,253 pass(es).
[ View ]
#59 DrupalDateTimeIntlTest.php_.tar_.gz862 bytesyuradoc
#57 resolving-pb-with-date-format-output_and_validation-2000384-57.patch10.64 KByuradoc
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch resolving-pb-with-date-format-output_and_validation-2000384-57.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]
#55 resolving-pb-with-date-format-output_and_validation-2000384-55.patch8.46 KByuradoc
PASSED: [[SimpleTest]]: [MySQL] 58,603 pass(es).
[ View ]
#48 resolving-pb-with-date-format-output_and_validation-2000384-48.patch7.9 KByuradoc
PASSED: [[SimpleTest]]: [MySQL] 58,718 pass(es).
[ View ]
#43 resolving-pb-with-date-format-output_and_validation-2000384-43.patch7.97 KByuradoc
PASSED: [[SimpleTest]]: [MySQL] 58,859 pass(es).
[ View ]
#41 resolving-pb-with-date-format-output_and_validation-2000384-41.patch8.57 KByuradoc
FAILED: [[SimpleTest]]: [MySQL] 58,487 pass(es), 6 fail(s), and 0 exception(s).
[ View ]
#38 resolving-pb-with-date-format-output_and_validation-2000384-38.patch8.2 KByuradoc
FAILED: [[SimpleTest]]: [MySQL] 57,712 pass(es), 144 fail(s), and 67 exception(s).
[ View ]
#34 resolving-pb-with-date-format-output_and_validation-2000384-34.patch5.57 KByuradoc
FAILED: [[SimpleTest]]: [MySQL] 59,157 pass(es), 9 fail(s), and 2 exception(s).
[ View ]
#32 resolving-pb-with-date-format-output_and_validation-2000384-32.patch5.75 KByuradoc
FAILED: [[SimpleTest]]: [MySQL] 58,724 pass(es), 9 fail(s), and 2 exception(s).
[ View ]
#26 resolving-pb-with-date-format-output_and_validation-2000384-26.patch8.33 KByuradoc
FAILED: [[SimpleTest]]: [MySQL] 59,048 pass(es), 9 fail(s), and 2 exception(s).
[ View ]
#22 Bildschirmfoto 2013-09-12 um 18.40.27.png109.74 KBderheap
#21 phpintl.JPG31.09 KBMicha1111
#21 phpversion.JPG131.16 KBMicha1111
#21 authored_on_error.JPG99.22 KBMicha1111
#18 2000384-datetime-format-broken.patch1.21 KBDamien Tournoud
PASSED: [[SimpleTest]]: [MySQL] 57,430 pass(es).
[ View ]
#2 d8_date_error_php5_4_9_intl.JPG31.71 KBMicha1111

Comments

Priority:Normal» Major
Issue tags:+intl

Closed #1992562: invalid "authored on" date as a duplicate of this, raising priority.

StatusFileSize
new31.71 KB

Same error here:

php 5.4.9 cgi-mode

intl server configuration attached

Ist not possible to save an edited article/page

Cannot reproduce error with the following config:

MAMP PHP 5.3.14
INTL version PECL-2.0.1
ICU version 51.1
ICU Data version 51.1

Head at 3cdae05

Can you try to run the DateTime tests, especially DateTimePlusIntl on your system and check if that's green?

██ cameron.tod @ macbookair-camerontod:~/Sites/drupal  (8.x)
██ 20:25:30 $ php -i | grep intl
intl
intl.default_locale => no value => no value
intl.error_level => 0 => 0
██ cameron.tod @ macbookair-camerontod:~/Sites/drupal  (8.x)
██ 20:25:33 $ php core/scripts/run-tests.sh --url http://local.drupal.org Datetime
Drupal test run
---------------
Tests to be run:
- Datetime Field (Drupal\datetime\Tests\DatetimeFieldTest)
- DateTimePlusIntl (Drupal\system\Tests\Datetime\DateTimePlusIntlTest)
- DateTimePlus (Drupal\system\Tests\Datetime\DateTimePlusTest)
- DrupalDateTime (Drupal\system\Tests\Datetime\DrupalDateTimeTest)
Test run started:
Saturday, May 25, 2013 - 21:25
Test summary
------------
Datetime Field 131 passes, 0 fails, and 0 exceptions
DateTimePlusIntl 14 passes, 0 fails, and 0 exceptions
DateTimePlus 54 passes, 0 fails, and 0 exceptions
DrupalDateTime 14 passes, 0 fails, and 0 exceptions

@cam8001 -- do you have the intl module installed that comes with PHP, or just the PECL module? This problem seems to happen with the intl module built into PHP (at least with 5.3 and later). On Red Hat / Fedora / CentOS systems, it is provided as part of the "php-intl" package.

Testing under Fedora, with PHP version 5.4.15 and MySQL version 5.5.31, from a fresh installation via git, 8.x branch at commit 08e824610c7c09e8bd0c023b756ee9712f649e12.

I have the following PHP packages installed:

php-channel-guzzle-1.3-2.fc18.noarch
php-cli-5.4.15-1.fc18.x86_64
php-phpunit-PHPUnit-3.7.20-1.fc18.noarch
php-soap-5.4.15-1.fc18.x86_64
php-symfony2-Yaml-2.2.1-1.fc18.noarch
php-symfony2-EventDispatcher-2.2.1-1.fc18.noarch
php-xml-5.4.15-1.fc18.x86_64
php-common-5.4.15-1.fc18.x86_64
php-gd-5.4.15-1.fc18.x86_64
php-PsrLog-1.0.0-2.fc18.noarch
php-twig-Twig-1.13.0-1.fc18.noarch
php-recode-5.4.15-1.fc18.x86_64
php-channel-phpunit-1.3-6.fc18.noarch
php-phpunit-File-Iterator-1.3.3-1.fc18.noarch
php-phpunit-PHP-TokenStream-1.1.5-1.fc18.noarch
php-pdo-5.4.15-1.fc18.x86_64
php-symfony2-BrowserKit-2.2.1-1.fc18.noarch
php-symfony2-Routing-2.2.1-1.fc18.noarch
php-EasyRdf-0.7.2-3.fc18.noarch
php-symfony2-Serializer-2.2.1-1.fc18.noarch
php-channel-ezc-1-5.fc18.noarch
php-mysql-5.4.15-1.fc18.x86_64
php-mbstring-5.4.15-1.fc18.x86_64
php-tidy-5.4.15-1.fc18.x86_64
php-phpunit-PHP-Invoker-1.1.2-1.fc18.noarch
php-symfony2-Finder-2.2.1-1.fc18.noarch
php-symfony2-DomCrawler-2.2.1-1.fc18.noarch
php-doctrine-DoctrineCommon-2.3.0-2.fc18.noarch
php-bcmath-5.4.15-1.fc18.x86_64
php-phpunit-Text-Template-1.1.4-1.fc18.noarch
php-symfony2-Process-2.2.1-1.fc18.noarch
php-symfony2-ClassLoader-2.2.1-1.fc18.noarch
php-5.4.15-1.fc18.x86_64
php-ezc-ConsoleTools-1.6.1-5.fc18.noarch
php-process-5.4.15-1.fc18.x86_64
php-symfony2-Config-2.2.1-1.fc18.noarch
php-channel-symfony2-1.3-1.fc18.noarch
php-redland-1.0.14.1-3.fc18.x86_64
php-pgsql-5.4.15-1.fc18.x86_64
php-symfony2-Console-2.2.1-1.fc18.noarch
php-phpunit-PHP-CodeCoverage-1.2.10-1.fc18.noarch
php-channel-doctrine-1.3-4.fc18.1.noarch
php-devel-5.4.15-1.fc18.x86_64
php-phpunit-PHPUnit-MockObject-1.2.3-1.fc18.noarch
php-pear-1.9.4-11.fc18.2.noarch
php-phpunit-PHP-Timer-1.0.4-1.fc18.noarch
php-ezc-Base-1.8-5.fc18.noarch
php-symfony2-DependencyInjection-2.2.1-1.fc18.noarch
php-symfony2-CssSelector-2.2.1-1.fc18.noarch
php-pecl-xdebug-2.2.2-1.fc18.x86_64
php-channel-twig-1.3-1.fc18.noarch

and will be testing with and without:

php-intl-5.4.15-1.fc18.x86_64

Output of php -m is:

[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dom
ereg
exif
fileinfo
filter
ftp
gd
gettext
gmp
hash
iconv
json
libxml
mbstring
mhash
mysql
mysqli
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_pgsql
pdo_sqlite
pgsql
Phar
posix
readline
recode
Reflection
session
shmop
SimpleXML
soap
sockets
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tidy
tokenizer
uploadprogress
wddx
xdebug
xml
xmlreader
xmlwriter
xsl
zip
zlib
[Zend Modules]
Xdebug

(obviously, this list also includes intl when I have that package installed.)

First of all, the test *without* php-intl installed

[jsmith@hockey drupal]$ php core/scripts/run-tests.sh --url http://drupal8.local Datetime
Drupal test run
---------------
Tests to be run:
- Datetime Field (Drupal\datetime\Tests\DatetimeFieldTest)
- DateTimePlusIntl (Drupal\system\Tests\Datetime\DateTimePlusIntlTest)
- DateTimePlus (Drupal\system\Tests\Datetime\DateTimePlusTest)
- DrupalDateTime (Drupal\system\Tests\Datetime\DrupalDateTimeTest)
Test run started:
Tuesday, May 28, 2013 - 09:12
Test summary
------------
FATAL Drupal\datetime\Tests\DatetimeFieldTest: test runner returned a non-zero error code (255).
- Found database prefix 'simpletest214786' for test ID 1.
[28-May-2013 09:12:18 America/New_York] PHP Fatal error:  Call to a member function bundle() on a non-object in /var/www/html/drupal/core/modules/datetime/lib/Drupal/datetime/Tests/DatetimeFieldTest.php on line 421
[28-May-2013 09:12:18 America/New_York] PHP Stack trace:
[28-May-2013 09:12:18 America/New_York] PHP   1. {main}() /var/www/html/drupal/core/scripts/run-tests.sh:0
[28-May-2013 09:12:18 America/New_York] PHP   2. simpletest_script_run_one_test() /var/www/html/drupal/core/scripts/run-tests.sh:22
[28-May-2013 09:12:18 America/New_York] PHP   3. Drupal\simpletest\TestBase->run() /var/www/html/drupal/core/scripts/run-tests.sh:482
[28-May-2013 09:12:18 America/New_York] PHP   4. Drupal\datetime\Tests\DatetimeFieldTest->testDateField() /var/www/html/drupal/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php:742
[28-May-2013 09:12:18 America/New_York] PHP   5. Drupal\datetime\Tests\DatetimeFieldTest->renderTestEntity() /var/www/html/drupal/core/modules/datetime/lib/Drupal/datetime/Tests/DatetimeFieldTest.php:125
- Removed test files directory.
- Removed 35 leftover tables.
DateTimePlusIntl 0 passes, 0 fails, and 0 exceptions
FATAL Drupal\system\Tests\Datetime\DateTimePlusIntlTest: Found no database prefix for test ID 2. (Check whether setUp() is invoked correctly.)DateTimePlus 54 passes, 0 fails, and 0 exceptions
DrupalDateTime 8 passes, 4 fails, and 8 exceptions
Test run duration: 27 sec

Now with the php-intl package installed:

[jsmith@hockey drupal]$ php core/scripts/run-tests.sh --url http://drupal8.local Datetime
Drupal test run
---------------
Tests to be run:
- Datetime Field (Drupal\datetime\Tests\DatetimeFieldTest)
- DateTimePlusIntl (Drupal\system\Tests\Datetime\DateTimePlusIntlTest)
- DateTimePlus (Drupal\system\Tests\Datetime\DateTimePlusTest)
- DrupalDateTime (Drupal\system\Tests\Datetime\DrupalDateTimeTest)
Test run started:
Tuesday, May 28, 2013 - 09:18
Test summary
------------
FATAL Drupal\datetime\Tests\DatetimeFieldTest: test runner returned a non-zero error code (255).
- Found database prefix 'simpletest622247' for test ID 5.
[28-May-2013 09:18:36 America/New_York] PHP Fatal error:  Call to a member function bundle() on a non-object in /var/www/html/drupal/core/modules/datetime/lib/Drupal/datetime/Tests/DatetimeFieldTest.php on line 421
[28-May-2013 09:18:36 America/New_York] PHP Stack trace:
[28-May-2013 09:18:36 America/New_York] PHP   1. {main}() /var/www/html/drupal/core/scripts/run-tests.sh:0
[28-May-2013 09:18:36 America/New_York] PHP   2. simpletest_script_run_one_test() /var/www/html/drupal/core/scripts/run-tests.sh:22
[28-May-2013 09:18:36 America/New_York] PHP   3. Drupal\simpletest\TestBase->run() /var/www/html/drupal/core/scripts/run-tests.sh:482
[28-May-2013 09:18:36 America/New_York] PHP   4. Drupal\datetime\Tests\DatetimeFieldTest->testDateField() /var/www/html/drupal/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php:742
[28-May-2013 09:18:36 America/New_York] PHP   5. Drupal\datetime\Tests\DatetimeFieldTest->renderTestEntity() /var/www/html/drupal/core/modules/datetime/lib/Drupal/datetime/Tests/DatetimeFieldTest.php:125
- Removed test files directory.
- Removed 35 leftover tables.
DateTimePlusIntl 14 passes, 0 fails, and 0 exceptions
DateTimePlus 54 passes, 0 fails, and 0 exceptions
DrupalDateTime 8 passes, 4 fails, and 8 exceptions
Test run duration: 28 sec

@jaredsmith - I was testing with the PECL module.

I can't recreate this on php 5.4.7 (xampp) and intl

version  1.1.0
ICU version  4.6.1
ICU Data version  4.6

No solution ?

Can not test D8 without saving nodes !

i have just installed drupal 8 and i get this error every time i try to create/edit a node, i'll try to dig in it tomorrow to see what's happening :)

Priority:Major» Critical

Bumping to critical.

I'm still seeing this on a fresh Drupal 8 installation via git as well.

Just for curiosity, I also tried this on PHP 5.5 (along with the 5.5 version of it's php-intl module):

[jsmith@hockey drupal]$ php -m
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dom
ereg
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
intl
json
libxml
mbstring
mhash
mysql
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_pgsql
pdo_sqlite
pgsql
Phar
posix
readline
recode
Reflection
session
shmop
SimpleXML
soap
sockets
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tidy
tokenizer
uploadprogress
wddx
xdebug
xml
xmlreader
xmlwriter
xsl
zip
zlib
[Zend Modules]
Xdebug

I try to run the tests, but they're now failing:

[jsmith@hockey drupal]$ php core/scripts/run-tests.sh --url http://drupal8.local Datetime
PHP Fatal error:  Call to undefined function simpletest_classloader_register() in /var/www/html/drupal/core/scripts/run-tests.sh on line 32
PHP Stack trace:
PHP   1. {main}() /var/www/html/drupal/core/scripts/run-tests.sh:0

Unfortunately, I still get the same results as I did with PHP 5.4.

+1 after fres install from GIT, unable to create nodes

+1 - unable to edit nodes
(I have this problem in Firefox, but not in Chrome)

See also comments on #2006484-31: Remove dependency on datetime from node and following.

Status:Active» Needs review
StatusFileSize
new1.21 KB
PASSED: [[SimpleTest]]: [MySQL] 57,430 pass(es).
[ View ]

Looking at the code, it seems we are missing a lot of those, everywhere. It's not completely obvious how to fix the field widget implementations, but this should at least go in the direction of fixing the form element.

Closed #2057295: php-intl support breaks node add page as another dupe of this. It has some nice steps to reproduce.

Component:base system» datetime.module

Moved to datetime.module per #2050763-16: Refine "base system" component (notes on refactoring of "base system" category here: https://docs.google.com/a/acquia.com/spreadsheet/ccc?key=0AusehVccVSq2dF...).

StatusFileSize
new99.22 KB
new131.16 KB
new31.09 KB

Same error again

PHP Version 5.4.16 nmm1 (CGI)

INTL 1.1.0
ICU 4.8.1.1
ICU Data 4.8.1

StatusFileSize
new109.74 KB

I spend some time inserting debug()-calls in the core.

I'm not able to tell why, but what is happing is more or less the following:

* When PHP-Itnl is present the correct(?) date and time from system.date_format.html_time.yml are loaded: Intl: 'H:mm:ss';
* But the PHP-Intl formatter is sometimes(?) not executed;
* Somtimes as some dates are correct …
* Instead the parent formatter is called and this is the normal PHP-DateTime formatter;
* This formatter produces from H:mm:ss the plain wrong time18:0909:0606 and date.

Maybe this helps.

I am just right now not able to write a test against it. It was my first peek into Drupal 8 core today. To much to learn for one day.

Like I described here https://drupal.org/node/2087505 I have pb with creating nodes.
I have built-in intl module in PHP. I did try both PECL and module:
version 1.1.0
ICU version 4.8.1.1
ICU Data version 4.8.1
I use Drupal 8-dev from GIT - 12.09.2013.
I use "XAMPP for Linux 1.8.3-0". You could try it to reproduce pb.

1. datetime.module function datetime_datetime_form_process has callings of the DrupalDateTime format function without second parameter where we must pass in array with key format_string_type (simeth like described in patch #18). Another functions has such pbs too. It must be changed here, I think, or DrupalDateTime and DateTimePlus format functions must be changed.

2. DrupalDateTime format function:
this line $format = preg_replace(array('/\\\\\\\\/', '/(?<!\\\\)([AaeDlMTF])/'), array("\xEF\\\\\\\\\xFF", "\xEF\\\\\$1\$1\xFF"), $format);
cause sometimes pb with creating new IntlDateFormatter at DateTimePlus format function.

3. datetime.module function datetime_datetime_validate not worked
$date = $input['object']; is null when validate executed I think $date = $element['#default_value'] must be used instead (not sure). After changes it starts work.

Assigned:Unassigned» derheap
Status:Needs review» Needs work

All calls in DateTime.Module to date->format() are missing the second parameter for the format type.
So the formating defaults to PHP, which leeds to the error.

I will try to work out a patch, and first look again on the patch from #18.

StatusFileSize
new8.33 KB
FAILED: [[SimpleTest]]: [MySQL] 59,048 pass(es), 9 fail(s), and 2 exception(s).
[ View ]

Hello. Please try my patch, I'm not sure it's OK fully, but resolves a pb for me.

Assigned:derheap» yuradoc
Status:Needs work» Needs review

Status:Needs review» Needs work

I think that patch fails because of the using DrupalDateTime format function without passing format_string_type in tests definations.
Check it for a while without automatic testing. Tests may need to be modify.

Assigned:yuradoc» Unassigned

I unassign myself because of my busy. Very interesting if somebody tested patch from #26.

The patch seems to work for me. But the tests are failing also localy.

Two things about the patch:

1/ You added an extra parameter to datetime_format_example(). That changes the the API. datetime_format_example() could/should call datetime_default_format_type() like datetime_html5_format() it does. That would make the patch smaller, we dont have to change that many function calls.

2/ Why the changes to lib/Drupal/Core/Datetime/DrupalDateTime.php? I don’t think they are related to the error.

I can’t fix the patch right now. Simpeltest is failing for me even with a fresh Drupal 8 repo right now.

Status:Needs work» Needs review
StatusFileSize
new5.75 KB
FAILED: [[SimpleTest]]: [MySQL] 58,724 pass(es), 9 fail(s), and 2 exception(s).
[ View ]

Hello. I make changes like described at #31.1. It placed in new patch.
The 2. DrupalDateTime I changed for two reasons:
1. $settings must be passed to the parent::format. It's related to this pb, because format_string_type needs to be passed too.
2. see #24.2. I comment it while this pb wouldn't be resolved.

One note: after some testing I found that some values pass validation that are wrong. It seems to me that date_parse and other functions that parse date, time from string has a bug. In validation I use DateTime::modify and it seems that it works the same like date_parse. Example 2013-0u-15.

Status:Needs review» Needs work

StatusFileSize
new5.57 KB
FAILED: [[SimpleTest]]: [MySQL] 59,157 pass(es), 9 fail(s), and 2 exception(s).
[ View ]

Sorry, found some bug. Reuploaded.

Status:Needs work» Needs review

Status:Needs review» Needs work

I spend some time on this patch.

1/ The changes to /core/lib/Drupal/Core/Datetime/DrupalDateTime.php are breaking some of the tests.
And for me the don't fix the bug.

2/ Most changes to datetime.module are working. Date and Time are displayed correct.

3/ This chunk is working, but is breaking the tests.

@@ -574,9 +575,10 @@ function datetime_datetime_validate($element, &$form_state) {
     }
     else {
       // If the date is valid, set it.
-      $date = $input['object'];
-      if ($date instanceOf DrupalDateTime && !$date->hasErrors()) {
-        form_set_value($element, $date, $form_state);
+      $date = $element['#default_value'];
+      $new_date = @$date->modify($input['date'].' '.$input['time']);
+      if ($new_date && $new_date instanceOf DrupalDateTime && !$new_date->hasErrors()) {
+        form_set_value($element, $new_date, $form_state);
       }
       // If the date is invalid, set an error. A reminder of the required
       // format in the message provides a good UX.

4/ Today I have found the reason:
The function form_type_datetime_value() reads the values from the form and creates an date object, if the formats are ok.
Thefore it calls DrupalDateTime::createFromFormat() which the calls the PHP Core DateTime::createFromFormat().
And this functions works only with normal PHP format strings. So the date is not valid, when it is called with an INTL format string.

So: Either we create a working createFromFormat function, that works with INTL format strings or scrape the whole INTL stuff alltogether and use only PHP formats.

Status:Needs review» Needs work
StatusFileSize
new8.2 KB
FAILED: [[SimpleTest]]: [MySQL] 57,712 pass(es), 144 fail(s), and 67 exception(s).
[ View ]

Hello. I made an experimental patch that contains modification of the createFromFormat.
I know that this function called by a lot of other places, so every changes must be done very careful. Please help to check it if it's work in most ways, maybe it requires some improvements.

Status:Needs work» Needs review

Status:Needs work» Needs review
StatusFileSize
new8.57 KB
FAILED: [[SimpleTest]]: [MySQL] 58,487 pass(es), 6 fail(s), and 0 exception(s).
[ View ]

Updated patch. Trying to remove some warnings.

Status:Needs review» Needs work

StatusFileSize
new7.97 KB
PASSED: [[SimpleTest]]: [MySQL] 58,859 pass(es).
[ View ]

Hello. I post patch again, sorry. Only now found how to use testing in WEB-interface of the D8 instalation.
Must be OK with passing.

Status:Needs work» Needs review

Status:Needs review» Needs work
Issue tags:-intl

Status:Needs work» Needs review
Issue tags:+intl

Cool! Automatically testings finished successfully.
Now guys, please help us to review this patch - may you have some notices or ideas for improving of the DateTimePlus::createFromFormat.
Big thanks to derheap for #37 and other comments. Also thanks to Damien Tournoud for patch #18 that helped me too.

StatusFileSize
new7.9 KB
PASSED: [[SimpleTest]]: [MySQL] 58,718 pass(es).
[ View ]

Hello. I removed some whitespaces, because git apply thrown them.

Status:Needs review» Needs work
Issue tags:-intl

Status:Needs work» Needs review
Issue tags:+intl

I tested the patch with PHP-Intl enabled.
I can now create a node and change the date.
There are no more mangled date-examples.

I tested again without PHP-Intl enabled.
Also no errors.

So for me the bug is fixed.

@everbody
I am new to the issue queque. What I am supposed to do now?

Thanks for reporting derheap.
Does anybody has some results too?
I have the same question - what to do next with patch?

I talked on IRC contribute chat. They said that users that made review of patch could set status to "reviewed & tested by the community".

yuradoc:

The next step, now that the 'manual testing' step is complete, is for someone to do a detailed patch review (which will look at the approach to solving the problem, coding standards, etc.).

Once that is complete, and if no issues found, the reviewer will update the issue to 'Reviewed and tested by community' status; otherwise they will update it to 'needs work' and identify any further changes which need to be taken.

See https://drupal.org/patch/review for more information on the patch review process.

StatusFileSize
new8.46 KB
PASSED: [[SimpleTest]]: [MySQL] 58,603 pass(es).
[ View ]

Hello.
I upload the patch that contains "Coding Standards" improvements founded after chattings with chx on #drupal-contribute IRC.

Closed #2074535: Warning: date_format() expects parameter 1 to be DateTime, boolean given in Drupal\node\NodeFormController->form() (line 202 of as a duplicate of this one.

Edit: undid this, does not seem to be the exact same issue.

StatusFileSize
new10.64 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch resolving-pb-with-date-format-output_and_validation-2000384-57.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

Hello. I upload patch with Unit Test included.

Status:Needs review» Needs work

StatusFileSize
new862 bytes

Hello - as previous patch is not possible to apply - please use #55.
I upload Unit Test separately (i made an archieve because it's not possible to upload php file). Please place file in "/core/modules/system/lib/Drupal/system/Tests/Datetime" folder. Don't forget clean test environment. After that test can be founded in Datetime group.

Status:Needs work» Needs review
StatusFileSize
new10.58 KB
PASSED: [[SimpleTest]]: [MySQL] 59,253 pass(es).
[ View ]

Updated patch with Unit Test.

Status:Needs review» Reviewed & tested by the community

Thanks, this looks really great!

StatusFileSize
new11.24 KB
PASSED: [[SimpleTest]]: [MySQL] 58,920 pass(es).
[ View ]
new1.36 KB

+++ b/core/lib/Drupal/Component/Datetime/DateTimePlus.php
@@ -205,20 +205,57 @@ public static function createFromFormat($format, $time, $timezone = NULL, $setti
-      // The createFromFormat function is forgiving, it might create a date that
+++ b/core/lib/Drupal/Core/Datetime/DrupalDateTime.php
@@ -124,7 +124,7 @@ public function format($format, $settings = array()) {
     $settings['calendar'] = !empty($settings['calendar']) ? $settings['calendar'] : $this->calendar;
     $settings['langcode'] = !empty($settings['langcode']) ? $settings['langcode'] : $this->langcode;
     $settings['country'] = !empty($settings['country']) ? $settings['country'] : $this->country;
-
+    $settings['format_string_type'] = $format_string_type;

I think this change can be neater. An expanded context is

    $format_string_type = isset($settings['format_string_type']) ? $settings['format_string_type'] : static::PHP;
    $settings['calendar'] = !empty($settings['calendar']) ? $settings['calendar'] : $this->calendar;
    $settings['langcode'] = !empty($settings['langcode']) ? $settings['langcode'] : $this->langcode;
    $settings['country'] = !empty($settings['country']) ? $settings['country'] : $this->country;
    $settings['format_string_type'] = $format_string_type;

So we're assigning $format_string_type based on $settings['format_string_type'] or a default just above. So we could assign $settings['format_string_type'] instead and use it. One less line of code to maintain :)

Attaching patch that does this - since this change is so minor leaving at rtbc.

Status:Reviewed & tested by the community» Fixed

Committed 5b3ff0d and pushed to 8.x. Thanks!

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

Editing the node form is apparently still broken when using intl and not having datetime.module enabled. See #2031183: Problems editing nodes if datetime.module is not enabled. Help would be very much welcome.