Skip to content

[4.0] Fix featured up and down null date checks in content table#26829

Merged
infograf768 merged 3 commits intojoomla:4.0-devfrom
richard67:4.0-dev-fix-featured-up-down-null-date-check
Oct 27, 2019
Merged

[4.0] Fix featured up and down null date checks in content table#26829
infograf768 merged 3 commits intojoomla:4.0-devfrom
richard67:4.0-dev-fix-featured-up-down-null-date-check

Conversation

@richard67
Copy link
Copy Markdown
Member

@richard67 richard67 commented Oct 26, 2019

Pull Request for Issue #26828 .

Summary of Changes

Remove the check for featured_up and featured_down times in the content table class.

The featured_up and featured_down columns have been added to database table #__content_frontpage with PR #25979 , thanks @eshiol for that new functionality and your patience.

During development, the new database columns first were added to table #__content and later have been mode to table #__content_frontpage.

This PR here removes a remainder of that change which causes the issue described in #26828 .

Thanks @Quy for having discovered the issue.

Testing Instructions

  1. Set php error reporting to E_ALL in your php.ini and switch on error logging to file or display of errors.
  2. Make a fresh installation of a clean, current 4.0-dev branch.
  3. When loging in to admin (backend) for the very first time, watch the PHP error log / error display.

Expected result

No errors or warnings or notices.

Actual result

PHP Notice: Undefined property: Joomla\Component\Content\Administrator\Table\ArticleTable::$featured_up in \libraries\src\Table\Content.php on line 278
PHP Notice: Undefined index: featured_up in \administrator\components\com_content\Model\ArticleModel.php on line 950
PHP Notice: Undefined index: featured_down in \administrator\components\com_content\Model\ArticleModel.php on line 950

Documentation Changes Required

None.

@Quy
Copy link
Copy Markdown
Contributor

Quy commented Oct 26, 2019

This is still an issue.

PHP Notice: Undefined property: Joomla\Component\Content\Administrator\Table\ArticleTable::$featured_up in \libraries\src\Table\Content.php on line 278

@richard67 richard67 changed the title [4.09] Fix featured up and down null date checks in content table [4.0] Fix featured up and down null date checks in content table Oct 26, 2019
@Quy
Copy link
Copy Markdown
Contributor

Quy commented Oct 26, 2019

Set to null if not set $this->featured_up and $this->featured_down.

@richard67
Copy link
Copy Markdown
Member Author

@Quy Ah it has been moved once from the #__content to the #__content_frontpage table!!! Here in the code for the content table it just has to be removed, I think. Will check.

@richard67
Copy link
Copy Markdown
Member Author

Or maybe saving to the #__content_frontpage is missing and has to be added?

@richard67
Copy link
Copy Markdown
Member Author

@Quy You can test with my latest commit but I am not sure if that is right. I think the Content.php is only for the #__content table.

@richard67
Copy link
Copy Markdown
Member Author

richard67 commented Oct 26, 2019

I've pinged George with a comment here, hope we will reply: #25979 (comment)

@Quy
Copy link
Copy Markdown
Contributor

Quy commented Oct 26, 2019

Notices are gone, however, featured dates don't swap when finish date is less than start date.

@richard67
Copy link
Copy Markdown
Member Author

Notices are gone, however, featured dates don't swap when finish date is less than start date.

I think this is the wrong fix then.

@richard67
Copy link
Copy Markdown
Member Author

@Quy It has been moved from the content table to the content frontpage table during development of that and there has been something forgotten for saving, that's what I think. Or can you check if changes on these dates are saved so you later see them when going back to the form from somewhere else?

@Quy
Copy link
Copy Markdown
Contributor

Quy commented Oct 26, 2019

Are you suggesting that lines 277 to 284 should not be there at all?

@Quy
Copy link
Copy Markdown
Contributor

Quy commented Oct 26, 2019

I do see them when editing.

@richard67
Copy link
Copy Markdown
Member Author

Yes, that's what I think. You can save changes in them? Gotta go now, brb later.

@Quy
Copy link
Copy Markdown
Contributor

Quy commented Oct 26, 2019

Yes changes are saved.

@richard67
Copy link
Copy Markdown
Member Author

And if you remove the code for those columns completely? Changed still saved?

@richard67
Copy link
Copy Markdown
Member Author

Am away from desk now, can’t test myself.

@Quy
Copy link
Copy Markdown
Contributor

Quy commented Oct 26, 2019

Yes.

@richard67
Copy link
Copy Markdown
Member Author

I think I've seen in changes of that PR that changes on these 2 new columns are saved by event trigger. So I think they should be removed here. @wilsonge If you find some time, please check and comment.

@richard67
Copy link
Copy Markdown
Member Author

@Quy And if we remove the complete function load(), too?

@richard67
Copy link
Copy Markdown
Member Author

Hmm, I see, the function is necessary to fill times in the edit form.

@richard67
Copy link
Copy Markdown
Member Author

@Quy Now it should be ok. Please test.

@richard67
Copy link
Copy Markdown
Member Author

@eshiol Could you check and review and maybe test, too?

@SharkyKZ
Copy link
Copy Markdown
Contributor

SharkyKZ commented Oct 26, 2019

The code for loading data for display should be moved to article model's getItem() method. Date sanity checks should be moved to model's featured() method and maybe to Joomla\Component\Content\Administrator\Table\FeaturedTable class. We don't really use the latter when saving though.

@richard67
Copy link
Copy Markdown
Member Author

@SharkyKZ I see. Will do that later.

@richard67
Copy link
Copy Markdown
Member Author

@SharkyKZ

The code for loading data for display should be moved to article model's getItem() method.

Will that work for frontend editing, too?

@SharkyKZ
Copy link
Copy Markdown
Contributor

No, that will have to be done in the frontend model as well.

Although I might be completely wrong with this suggestion. To me it seems that table class shouldn't load properties from other tables. But then Joomla\CMS\Table\User does exactly that with groups. So I'm not sure anymore.

@richard67
Copy link
Copy Markdown
Member Author

@SharkyKZ I get an error 1054 Unknown column 'featured_up, featured_down' in 'field list' when testing your suggested change and opening the article for edit. The swapping of the dates is rubbish anyway, I'll leave that away. Other sanity checks seem already to be done.

@richard67
Copy link
Copy Markdown
Member Author

@SharkyKZ @Quy Please test. Main thing is the PHP notices go away and all works well. Architectural improvements should be considered for future PR's.

@Quy
Copy link
Copy Markdown
Contributor

Quy commented Oct 26, 2019

I have tested this item ✅ successfully on f8557aa


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

@richard67
Copy link
Copy Markdown
Member Author

@infograf768 Could you test this here, too?

@brianteeman
Copy link
Copy Markdown
Contributor

I have tested this item ✅ successfully on f8557aa

tested with the json api


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

@SharkyKZ
Copy link
Copy Markdown
Contributor

RTC


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

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Oct 26, 2019
@infograf768 infograf768 merged commit 43a3e0e into joomla:4.0-dev Oct 27, 2019
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Oct 27, 2019
@infograf768
Copy link
Copy Markdown
Member

tks

@infograf768 infograf768 added this to the Joomla 4.0 milestone Oct 27, 2019
@richard67
Copy link
Copy Markdown
Member Author

tested with the json api

@brianteeman Was your test maybe for #26825 and not this one here? Just to be sure all is right.

@richard67 richard67 deleted the 4.0-dev-fix-featured-up-down-null-date-check branch October 27, 2019 07:55
@brianteeman
Copy link
Copy Markdown
Contributor

my test was for here

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.

6 participants