?
avatar JamesNGarrett
JamesNGarrett
13 May 2017

Steps to reproduce the issue

  1. Create a category.
  2. Create a content > field group.
  3. Create a content > field and add this field to the field group and assign to the category made in step 1
  4. Set the Global Config to a timezone - anything without an offset of 0 will do
  5. Create and save an Article
  6. Change the article's category causing the page to refresh due to the custom field
  7. Switch to the Publishing tab
  8. Look at the Start Publishing and Created Date entries
  9. Gasp in horror

Expected result

Once the article is saved the start publishing and created date fields should not change unless the user changes them

Actual result

The timezone offset is added to / subtracted from both dates every time the category is changed - thus causing issues with new articles being pending.

System information (as much as possible)

Tested on cloud linux cpanel and a ubuntu 14 vm
Tested on php7.0 and 5.6
Tested on Joomla 3.7.0 and 3.7.1 RC1
Tested with both TinyMCE and JCE

avatar JamesNGarrett JamesNGarrett - open - 13 May 2017
avatar joomla-cms-bot joomla-cms-bot - change - 13 May 2017
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 13 May 2017
avatar joomla-cms-bot joomla-cms-bot - change - 13 May 2017
Title
[com_fields] Timezone offset added to Article Publishing Dates when changing categories if fields are applying to categories.
Timezone offset added to Article Publishing Dates when changing categories if fields are applying to categories.
avatar joomla-cms-bot joomla-cms-bot - edited - 13 May 2017
avatar franz-wohlkoenig franz-wohlkoenig - change - 13 May 2017
Title
Timezone offset added to Article Publishing Dates when changing categories if fields are applying to categories.
[com_fields] Timezone offset added to Article Publishing Dates when changing categories if fields are applying to categories.
avatar joomla-cms-bot joomla-cms-bot - change - 13 May 2017
Title
Timezone offset added to Article Publishing Dates when changing categories if fields are applying to categories.
[com_fields] Timezone offset added to Article Publishing Dates when changing categories if fields are applying to categories.
avatar franz-wohlkoenig franz-wohlkoenig - change - 13 May 2017
Category com_fields
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 13 May 2017

Confirmed.

Set Timezone on "Chicago", Published Time is (7h earlier) 2017-05-13 01:41. After change Article to Category using com_fields Published Time is 2017-05-12 20:41.

avatar joomla-cms-bot joomla-cms-bot - change - 13 May 2017
Title
Timezone offset added to Article Publishing Dates when changing categories if fields are applying to categories.
[com_fields] Timezone offset added to Article Publishing Dates when changing categories if fields are applying to categories.
avatar joomla-cms-bot joomla-cms-bot - edited - 13 May 2017
avatar franz-wohlkoenig franz-wohlkoenig - change - 13 May 2017
Status New Confirmed
avatar joomla-cms-bot joomla-cms-bot - change - 13 May 2017
Title
[com_fields] Timezone offset added to Article Publishing Dates when changing categories if fields are applying to categories.
Timezone offset added to Article Publishing Dates when changing categories if fields are applying to categories.
avatar photodude
photodude - comment - 14 May 2017

I think this has been addressed in 3.7.1 with the fix the JDate, perhaps someone can confirm that this has been fixed.

avatar fmmarmello
fmmarmello - comment - 1 Jun 2017

Hello folks,
any comment on this?
Having this issue in 3.7.2 :(

avatar gabrielnazario25
gabrielnazario25 - comment - 5 Jun 2017

I am experiencing the exact same issue, in Joomla 3.7.2

avatar andrepereiradasilva
andrepereiradasilva - comment - 6 Jun 2017

confirmed ... why does changing category with fields changes the article published and created date!?!?!
this is not related to the JDate issue in 3.7.0

This is probably some JS behaviour that is doing this

avatar andrepereiradasilva
andrepereiradasilva - comment - 6 Jun 2017

The reload is caused by categoryHasChanged js function that is submitng the article form to com_fields and, with it, sending all the article form data.

Com_fields receives the article form data and redirect the app back to the article edit view (which now loads the wrong date).

@dgt41 any idea why the article form load event from user state uses the wrong date in this scenario (different timezone)? Could it be something related to the calendar?

avatar dgt41
dgt41 - comment - 6 Jun 2017

This is probably some JS behaviour that is doing this

I think is the way the data is passed to the form the second time (2 transformations === wrong time)
Javascript should always parse and print (send to PHP) UTC dates new Date("2017-03-25T12:00:00-06:30"); but that was out of question for J3.x due to B/C break, maybe in J4?

@mbabker @wilsonge can we change the value of form field calendar to 2017-03-25T12:00:00-06:30?

avatar andrepereiradasilva
andrepereiradasilva - comment - 6 Jun 2017

i think the second time the date is 2017-03-25 12:00:00 format

avatar dgt41
dgt41 - comment - 6 Jun 2017

Let's ping @laoneo here, he's more familiar with the Fields code

avatar laoneo
laoneo - comment - 7 Jun 2017

I will have a look together with @Bakual. Not an easy one to fix to keep everything intact. Basically the validate function does need to be called. From a first glance I have no clue how.

avatar Bakual
Bakual - comment - 7 Jun 2017

Yep, that's indeed not an easy fix. Running the validate method (which would apply the tz difference back) would require that we know the form (the XML) itself, but we don't know that at this point. Also it would mean that it fails when the form is invalid (eg no title yet). So it's not a viable solution imho.

Basically the current solution to reload the whole form with new custom fields is sort of a hack.

Ideally we would use some AJAX which replaces the custom fields (and fieldsets) itself with the new ones directly without reloading the whole form. But that is probably not that easy as well due to the possibility of template overrides. But I'd say it is the most promising approach (my JS skills lack me here however)

If we had an "autosave" feature which saves the current work into an "autosave version" in the version history, then that one could be used for the reloading. But while that would be an interesting feature, it needs someone to write it first and it's probably not simpler 😄

avatar fmmarmello
fmmarmello - comment - 7 Jun 2017

What about saving the original value (from DB) in State, Session or LocalStorage..
Overwrite this if the user changes the field .. maybe ? If not, we apply TZ to the "original" value

avatar Bakual
Bakual - comment - 7 Jun 2017

To decide if the TZ has to be applied or not (and which one, server or user TZ), you need the form definition. That one as well as the original value isn't available in the browser. So you can't do anything here. Maybe we could make it available to the browser somehow, but in the end it would just be another hack specific to fields and calendar formfields.
On server side, we already have the validate method which does change the value back based on TZ settings and form definition. So if we have to deal with it on the server, we already have the method to do it. What we don't have within com_fields at this point is the form definition.

avatar laoneo
laoneo - comment - 7 Jun 2017

A way would be to go over the controller of the extension (eg. ContentControllerArticle) to store the data into the session instead of the com_fields controller, just with another task like reload for example.

avatar laoneo
laoneo - comment - 13 Jun 2017

Please test #16665 which should fix the issue.

avatar brianteeman
brianteeman - comment - 13 Jun 2017

Closed as we have a PR for testing

avatar brianteeman brianteeman - close - 13 Jun 2017
avatar brianteeman brianteeman - change - 13 Jun 2017
Status Confirmed Closed
Closed_Date 0000-00-00 00:00:00 2017-06-13 11:34:59
Closed_By brianteeman

Add a Comment

Login with GitHub to post a comment