Skip to content

[4.0] Null date corrections for Jgrid and Published buttons#26751

Merged
wilsonge merged 7 commits intojoomla:4.0-devfrom
infograf768:4.0_nulldate
Oct 25, 2019
Merged

[4.0] Null date corrections for Jgrid and Published buttons#26751
wilsonge merged 7 commits intojoomla:4.0-devfrom
infograf768:4.0_nulldate

Conversation

@infograf768
Copy link
Copy Markdown
Member

Pull Request for Issue #26660

Summary of Changes

Null Date is now defined by null and no more by Factory::getDbo()->getNullDate()

Testing Instructions

Create a site or admin module and enter a date for the Start Publishing.
Although no Finish Publishing date is set, the tooltip will display a wrong finish date.

Before patch

Screen Shot 2019-10-21 at 11 17 21

After patch

Screen Shot 2019-10-21 at 11 16 05

Note:

Remains in core 3 files with instances of Factory::getDbo()->getNullDate()

/layouts/joomla/content/icons/edit.php:25: 		|| ((strtotime($article->publish_down) < strtotime(Factory::getDate())) && $article->publish_down != Factory::getDbo()->getNullDate()))
/layouts/joomla/content/icons/edit.php:35: 		|| ((strtotime($article->publish_down) < strtotime(Factory::getDate())) && $article->publish_down != Factory::getDbo()->getNullDate()))
/libraries/src/Form/Field/CalendarField.php:228: 				if ($this->value && $this->value != Factory::getDbo()->getNullDate())
/libraries/src/Form/Field/CalendarField.php:240: 				if ($this->value && $this->value != Factory::getDbo()->getNullDate())
/libraries/src/Form/Field/CalendarField.php:253: 		if ($this->value && $this->value != Factory::getDbo()->getNullDate() && strtotime($this->value) !== false)
/libraries/src/HTML/HTMLHelper.php:1115: 		if ($value && $value !== Factory::getDbo()->getNullDate() && strtotime($value) !== false)

I did not touch these as I was not sure where to test them.

@richard67
Copy link
Copy Markdown
Member

@infograf768 Was on my task list, but you were faster. Code looks good to me. Will test tonight after work.

@infograf768
Copy link
Copy Markdown
Member Author

@richard67
There are many other variations of ->getNullDate ;)

@richard67
Copy link
Copy Markdown
Member

@infograf768 I know. Not all of them shall be thrown away, some of them we need to keep for 3rd party extensions. But a check for real NULL should be added. Maybe @wilsonge can check hf the changes here are ok. To me they seem to be ok.

@ChristineWk
Copy link
Copy Markdown

ChristineWk commented Oct 21, 2019

I have tested this item ✅ successfully on d5feaae

Confirm Before Patch & After Patch, but on both I hv this.
Info: Tested on beta-1 (nightly from yesterday)


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/26751.

@ChristineWk
Copy link
Copy Markdown

see attached.screen shot 2019-10-21 at 10 09 38screen shot 2019-10-21 at 10 09 42


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/26751.

@infograf768
Copy link
Copy Markdown
Member Author

@ChristineWk
The date is in the past.
Please try to also modify Factory::getDbo()->getNullDate() to null in

/layouts/joomla/content/icons/edit.php:25: 		|| ((strtotime($article->publish_down) < strtotime(Factory::getDate())) && $article->publish_down != Factory::getDbo()->getNullDate()))
/layouts/joomla/content/icons/edit.php:35: 		|| ((strtotime($article->publish_down) < strtotime(Factory::getDate())) && $article->publish_down != Factory::getDbo()->getNullDate()))

@HLeithner
Copy link
Copy Markdown
Member

If we want to support 3rd party extensions with this layout which doesn't null as date type we have to keep getNullDate and just add a === NULL to the if-statement.

If we don't want to support this, you can remove the $nullDate variable completely. Since we still have getNullDate in the near future (4.x) we should support it in the layout too.

Please change
($publish_up != $nullDate)
to
($publish_up !== NULL &&$publish_up != $nullDate)

thx

@richard67
Copy link
Copy Markdown
Member

Please change
($publish_up != $nullDate)
to
($publish_up !== NULL &&$publish_up != $nullDate)

Should be lowercase nullfor PHP CS.

@infograf768 In PublishedButton.php the checks in lines 89 and 95 should also be corrected. They were wrong before nulldate changes, too, because in lines 63 and 64 the datetimes are set to null. If you want I can check tonight after work and send you a PR to your branch.

@infograf768
Copy link
Copy Markdown
Member Author

@richard67

If you want I can check tonight after work and send you a PR to your branch.

Thanks, please do and correct all.

@richard67
Copy link
Copy Markdown
Member

@wilsonge Shall JGrid or the Published Buttons be usable by 3rd party extensions so we have to keep old nulldate checks here?

@ChristineWk
Copy link
Copy Markdown

@infograf768

Trashed previous and made new with tomorrow date :-)

null_date_03
null_date_04
Hv also to read new comments. Should I delete successful?

@brianteeman
Copy link
Copy Markdown
Contributor

@wilsonge Shall JGrid or the Published Buttons be usable by 3rd party extensions so we have to keep old nulldate checks here?

Of course they must be - they are part of the librarries

@wilsonge
Copy link
Copy Markdown
Contributor

Yup we need to keep compat in the libraries please. but we can definitely mark as deprecated

[4.0] Check for both old (pseudo-)null dates and real NULL values in Jgrid and Published buttons
@infograf768
Copy link
Copy Markdown
Member Author

I merged @richard67 patch into this. It works fine for me.

Do we also need to modify /layouts/joomla/content/icons/edit.php ?
It looks like it is only used for legacy:

$text = LayoutHelper::render('joomla.content.icons.edit', array('article' => $article, 'overlib' => $overlib, 'legacy' => $legacy));

@ChristineWk
Please test again.

@richard67
Copy link
Copy Markdown
Member

@wilsonge I don't know what exactly to mark as deprecated.

@brianteeman
Copy link
Copy Markdown
Contributor

Do we also need to modify /layouts/joomla/content/icons/edit.php ?

That was for the icon on front end editing iirc

@ChristineWk
Copy link
Copy Markdown

@infograf768

hv similar the same as before.
null_date_05

@richard67
Copy link
Copy Markdown
Member

@ChristineWk If I understand the functionality right, the above is correct. Pending means publish up is in future. Today is the 21st.

@richard67
Copy link
Copy Markdown
Member

Or do I maybe understand the issue wrong?

@richard67
Copy link
Copy Markdown
Member

I have tested this item ✅ successfully on d0128ab

Before patch: A publish down time is shown in the tool tip even if no publish down time was set.

After patch: Publish down time is only shown if really set.

The icon and tool tip is set according to the times (expired if publish down in past, pending if publish up in future, published if publish up in past and publish down in future or no publish down set).


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/26751.

@ChristineWk
Copy link
Copy Markdown

I have tested this item ✅ successfully on d0128ab


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/26751.

@Quy
Copy link
Copy Markdown
Contributor

Quy commented Oct 21, 2019

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/26751.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Oct 21, 2019
@richard67
Copy link
Copy Markdown
Member

If nobody else wants to do that, I will make another PR for /layouts/joomla/content/icons/edit.php ... but it may take a while, not sure if I will get it finished otday with testing instructions.

@infograf768
Copy link
Copy Markdown
Member Author

@Quy @wilsonge
Please merge.

@wilsonge wilsonge merged commit 6215038 into joomla:4.0-dev Oct 25, 2019
@wilsonge
Copy link
Copy Markdown
Contributor

Thanks!

@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Oct 25, 2019
@wilsonge wilsonge added this to the Joomla 4.0 milestone Oct 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants