Skip to content
This repository has been archived by the owner on Sep 17, 2018. It is now read-only.

Suggestion for displaying Dates in view updates files #52

Merged
merged 8 commits into from
Jul 25, 2018
Merged

Conversation

astridx
Copy link
Contributor

@astridx astridx commented Jul 20, 2018

Pull Request for Issue #42.

Summary of Changes

  1. Note the time zone for the creation date
  2. Do not use date of file for showing the modified date in view updated files. Instead of that use date of update.

Testing Instructions

  1. Install an extension
  2. Create an override
  3. Update the extension

Expected result

Creation date and modified date are the same in view updated files in case of the first update.
templates customise cassiopeia test administration 29

Modified date is the of the last update, in case of many updates.
templates customise cassiopeia test administration 30

Actual result

You have a delay depending on your time zone for creation date.

@@ -90,7 +90,7 @@ protected function storeFileInfo($path, $name, $template)

if ($coreFile = $this->getCoreFile($path . $name, $template->client_id))
{
$temp->modifiedDate = date("y-m-d h:i:s.u", filemtime($coreFile));
$temp->modifiedDate = date("Y-m-d H:i:s", filemtime($coreFile));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not necessary here. I only add it for making the date similar to use the format in Joomla\CMS\Date\Date;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with this we can use :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now this is fine.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is missing here is timezone conversion. I'm not sure in what for a timezone the file timestamps are defined but date takes into account the server timezone and we need to store the dates in UTC.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@laoneo Yes, we are storing DateTimeZone of the server in UTC.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@astridx Can you please remove $temp->modifiedDate because we no longer using this right ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And, remove unset($after[$i]->coreFile); in override plugin line 145.


if (empty($pk->modifiedDate))
$pk->modifiedDate = '0000-00-00 00:00:00';
if (!empty($pk->modifiedDate))
Copy link
Member

@anuragteapot anuragteapot Jul 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, we never get $pk->modifiedDate empty right? So, modifiedDate is always $createdDate?
In without this PR or previous. When the core file is removed not updated. We did not get modified date because core file is removed right ?
Then, we show the in override list that core file removed.
So, i think just add $pk->modifiedDate = '0000-00-00 00:00:00'; after if statment or condition . Then, its fine ?

@astridx
Copy link
Contributor Author

astridx commented Jul 21, 2018

@Anu1601CS Many Thanks. I had not considered the case that the file was deleted. Now it should be OK, right?

$tz = new \DateTimeZone(Factory::getApplication()->get('offset'));
$date = new Date('now');
$date->setTimezone($tz);
$createdDate = $date->toSql(true);

if (empty($pk->modifiedDate))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And, here you can check empty of $pk->coreFile right?

@astridx
Copy link
Contributor Author

astridx commented Jul 21, 2018

@Anu1601CS
You're right. I have planned to check if we need the date of the file at all.
I made the changes you suggested. But: The behavior was not as I expected. I have to take a little more time for this. Unfortunately, I do not have much time before Tuesday. If you like, we can merge this branch. So you have the correct views for the documentation.

We can make an issue for deleting unnecessary program code.

@anuragteapot
Copy link
Member

@astridx If you are not free. So, can I make changes to it ?

@ghost
Copy link

ghost commented Jul 21, 2018

@Anu1601CS Yes, of course

@anuragteapot
Copy link
Member

@astridx Done! I hope, I did not make any mistake.

{
$pk->modifiedDate = '0000-00-00 00:00:00';
$modifiedDate = '0000-00-00 00:00:00';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we can take the null date from the database driver to stay on the safe side.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@astridx Can you please take a look?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@laoneo Do you mean this: 2698f34

$tz = new \DateTimeZone(Factory::getApplication()->get('offset'));
$date = new Date('now');
$date->setTimezone($tz);
$createdDate = $date->toSql(true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has to be stored in UTC or not?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can store the time in the user time zone.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? How do you want to handle then different timezones and DST?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has to be stored in UTC or not?

If I am right, it is automatically UTC, as UTC is the default time zone in Joomla\CMS\Date\Date (/libraries/src/Date/Date.php).

@anuragteapot
Copy link
Member

@laoneo Can you please test this PR ?

@astridx astridx merged commit 2c393ff into master Jul 25, 2018
@anuragteapot anuragteapot deleted the dates branch July 26, 2018 07:00
@laoneo
Copy link
Contributor

laoneo commented Jul 26, 2018

Why did you merge this one? It is wrong, dates should never be stored in the user timezone.

@astridx
Copy link
Contributor Author

astridx commented Jul 26, 2018

@laoneo How do you like it? Should we store the UTC value in the database and convert it only for display? Or should we even display the UTC value?

@anuragteapot
Copy link
Member

@astridx I store UTC value in database.

@laoneo
Copy link
Contributor

laoneo commented Jul 26, 2018

That's what Joomla does, dates are stored in UTC and are displayed in the timezone of the user.

@astridx
Copy link
Contributor Author

astridx commented Jul 26, 2018

@laoneo OK. I will change it. I will do this in a new PR, ok? Or should I revert the old one?

@laoneo
Copy link
Contributor

laoneo commented Jul 26, 2018

There are two things here to test:

  • date("y-m-d h:i:s.u", filemtime($coreFile)); this is always in the timezone of the server if I'm not wrong.
  • $createdDate = $date->toSql(true);has to be $createdDate = $date->toSql();

You can easily test it by changing the Joomla timezone to something like Sidney and the user timezone to something completely different. And when DSt kicks in, we are screwed even more. I wen through all of that with DPCalendar 🙈

zero-24 pushed a commit that referenced this pull request Sep 6, 2018
* Load correct core files of override files (#2)

Start implements loadcorefile() in administrator/components/com_templates/Model/TemplateModel.php

* CS (#3) Coding Standards

* codingstandards

* codingstandards (#4)

* Test (#6)

Phase 2 (2 part) Mechanism to find correct core file and implementation.

* Remove Notice: Only available for html-folder

* Remove Warning if core file not found (#11)

Thanks.
So one part of the issue #12 is done.

* Implement the diff view in template manager 

Implement the diff view in template manager

* coding standard (#17)

* fix diff (#18) Fix bug in path in case of administrator template override.

Fix bug in path in case of administrator template override.

* Notification after update and TEST (#16)

Find changed files of overridden files and show message.

* coding standard (#21)

* correction

* correction (#26)

* Correcthtmlpath (#27)

* correction

* change oldhtml to newhtml

* List of updated override files. (#30)

* addcss (#34)

* Final Product  (#39)

Core and Diff view
Updated override history list.
Quick icon notification plugin.
Override control plugin.

* save 3 lines :)

* New feature show status. (#47)

show status in com_template view templates

* link

* corrected namespace

* Button to Switch (#35)

* wip add Switcher

* wip style switcher

* wip style switch make inline and change on off text

* wip start with js

* wip js

* wip delete buttons and make js more robust

* wip save to storage

* wip delete old code

* wip

* wip lint

* wip css

* set default value for switcher

* wip make switcher blue

* wip

* wip

* build

* correct names

* create new functions

* fist test code

* use onchange

* undo installer.min.js

* add forgotten new line at the end of css file

* correct align

* correct compare.es6 - only deleted the toggle part

* correct compare.js - only deleted the toggle part

* wip

* reduce timeout

* wrap in funcitons

* wip

* add use strict to both js-files(compare and toggle)

* add the timeout value of 500 again, because 200 are not enought in my case

* use css class 'active' for toggle views

* add strict

* time out for editor

* wip

* improvments use newActive and switch

* correction

* width of switcher-spans

* correct align

* do not use global

* wip

* removed timeouts

* JTEXT to TEXT

* forgotton last line

* deleted duplicated comments

* css fix align

* use unnamed functions in es6

* Sql files for fix database (#50)

* sql files for database fix

* delete space

* Suggestion for displaying Dates in view updates files (#52)

Correct Dates and do not use date of file any more

* Store Date as UTC and show it in server time zone (#57)

* modified and created date are created and stored in UTC

* convert dates for displaying in model

* spar a loop

* normalize timezone in view

* use language constants for dateformat

* JToolbarHelper to ToolbarHelper

* CS

* namespace

* plural

* name

* clean

* text

* fx

* sin

* files

* s

* Suggestion for language strings (#60)

* language strings

* correct typo

* delete media folder plg_quickicon

* add folder plg_quickicon to build/media_src

* delete files in media folder

* Move media folder - System (#66)

* multi

* cs

* delete files in media folder for joomla toolbar (#67)

* Fix button switchers style. (#70)

* button

* CS

* changed uitab.addTab for updated files

* Bring back core.js changes. (#69)

* core.js

* const

* fix

* form

* core

* hound

* CS

* scopr

* grid

* alpha

* cs

* lang

* only override file

* lang

* override lang installer

* Cs

* sub

* Update list of core extensions (#71)

* Language changes (#76)

* update

* Update en-GB.com_templates.ini

* override JLIB_HTML_PUBLISH_ITEM

this is the hover text on the publish icon in the list of files

* Change icon (#74)

change the icon to use an outline for more consistency

* lang

* not core (#75)

* not core

* Update en-GB.plg_installer_override.ini

* namespace

* cs

* Updated files (#82)

* Update default_updated_files.php

* Update en-GB.com_templates.ini

* Update en-GB.com_templates.ini (#81)

* Update en-GB.plg_quickicon_overridecheck.ini (#80)

* Update en-GB.plg_quickicon_overridecheck.ini (#79)

* remove space (#78)

* Update en-GB.plg_quickicon_overridecheck.ini

* Update en-GB.plg_quickicon_overridecheck.sys.ini

* remove hardcoded id

* null get function

* state

* clean

* More changes "core" to "original" (#85)

* cs

* update

* plural
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants