Closed (fixed)
Project:
Scheduler
Version:
2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
18 Jan 2022 at 17:51 UTC
Updated:
11 Nov 2022 at 09:14 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #3
jonathan1055 commentedHi,
Are you planning or writing a scheduler plugin for the Paragraphs entity type? I am about to post the documentation on this, which should help you.
Comment #4
anybody@jonathan, no I just documented the issue. Anyone may implement it. :)
Comment #5
dieterholvoet commentedComment #6
dieterholvoet commentedI pushed a working plugin implementation to the MR. I had to do some extra changes since this module didn't account yet for entities without canonical/edit-form link templates.
Comment #8
jonathan1055 commentedThanks DieterHolvoet for providing the plugin and the fix for edit link.
As I've not used Parapgraphs or Layout Paragraphs before, could you give a few quick steps to follow so that I can test you work. I know I could do my own research and work it out for myself, but as you (or anyone else following here) are already experienced with Paragraphs it would be quicker for you.
This looks like a good addition for committing before I release 2.0, but I need to be able to test it in the way you are doing. Thanks
Comment #9
dieterholvoet commentedHere are the steps for testing with the Paragraphs module. I have no experience with the Layout Paragraphs module.
composer require drupal/paragraphs && drush en paragraphs -yComment #10
jonathan1055 commentedThanks DieterHolvoet, that's helpful. I followed through, and have sucessfully created paragraphs and scheduled them. All works fine in general, so that's a good start.
Some points I noticed:
Step 1. When installing (via drush and via site UI) we get the exception
Failed to read source file for views.view.scheduler_scheduled_paragraph from either modules/scheduler/config/install or modules/scheduler/config/optional folders. This is because Scheduler does not (yet) provide any view for listing the scheduled paragraphs. SoI have changed this to a dblog notice, as there is no real need for it to be an exception. We need to work out if and how Scheduler can provide a view for a user to find their own scheduled paragraphs. Or maybe this is not possible, or not needed. Any ideas?Step 2. When creating the Paragraph content type, it needs at least one field to be added (this was missing from above)
Step 3. When adding the paragraph to the node type, I used the default reference method. Also need to tick 'include the selected below' and tick the paragraph content type
Step 4. On saving the node we get message the Scheduler message is
{node title} > {my paragraphs label} (previous revision) is scheduled to be unpublished ..... This message basically applies to the whole paragraphs section. If there are several paragraphs added but only one is scheduled I don't know if there is a better way to indicate which specific paragraph is scheduled? Maybe we can't do that, and the general message is good enough?Comment #11
dieterholvoet commentedComment #12
dieterholvoet commentedWe could add a view. Don't really have the time to do that right now though.
I updated the testing instructions and added them to the issue description.
That logic comes from
Drupal\paragraphs\Entity\Paragraph::label(), it's how the paragraphs module decided to label its entities. If we wanted to override that logic on a per-entity type basis we would have to move most logic fromscheduler_entity_presaveto the Scheduler plugins, or we could add anentityLabel(EntityInterface $entity)method toSchedulerPluginInterface. Not sure if all that is worth the effort.Comment #13
jonathan1055 commentedThanks for updating the issue summary.
Regarding a view, I will take a quick look, but even if we had a view I'm note sure where it would be displayed. Maybe on /admin/structure/paragraphs_type like we do for Commerce Products. There could be a user view on the profile tab too. But it may all be too much trouble.
For the warning I have created #3311425: Replace warning for no entity type with an explanation in the menu to avoid that being wrapped up in this issue.
For the scheduler message let's leave this as is. It is fine.
The first release of Scheduler 2.0 is almost here. Are you happy with this work so far, it would be nice for this to be in the first major release.
Comment #14
dieterholvoet commentedLet's leave the paragraphs view, paragraphs are only really relevant in context of their parent anyway.
Yeah, I'm happy with the work so far. I think this is ready to merge.
Comment #16
jonathan1055 commentedYes we can leave the view out for now. It can always be added as a follow-up issue.
Merged and fixed. Thanks DieterHolvoet for doing most of this work.
Comment #17
jonathan1055 commentedFollow-up issue #3312200: Paragraph scheduler plugin is needed because hook_form_alter is not called for referenced entities. It can be solved using hook_field_widget_complete_WIDGET_form_alter() for paragraph widgets.
This error would have been discovered if Paragraphs could be easily added into Scheduler's generic testing. However, the method for adding and editing a paragraph is not the same as other supported entities due to paragraphs being added to nodes and not being standalone entities. It would be very good to expand the tests to cover Paragraphs.
I have also found that the third-party settings for paragraph are missing from config/schema/scheduler.schema.yml so that has been added too.
Comment #18
jonathan1055 commentedI have decided to revert and remove the paragraphs plugin, as it is clear that it is not fully working with all the scheduler features. I have solved some of the problems on #3312200: Paragraph scheduler plugin but there is still the major problem that hook_form_alter is not being called for the paragraph entities when adding a new node which has paragraphs. That's a big problem because all users that have Paragraphs and Scheduler installed will always see the scheduer fields when adding the node, even if Scheduler is not enabled for the paragraphs.
I am sure it can be solved, but right now we are working towards the first 2.0 release and the paragraphs plugin was a last-minute addition. It can be worked on as soon as 2.0 is released.
Do you know if a new hook_update has to be written to remove the publish_on and unpublish_on fields that were added in your scheduler_update_8205() ? For those users who installed 2.0-rc5 and have Paragraphs installed there could be a problem if the plugin is removed?
Comment #19
dieterholvoet commentedNot immediately and I don't think I'll have time to work on this during the coming week. We'd probably have to update
SchedulerManager::entityUpdateor add a new method for handling removing fields.Comment #20
jonathan1055 commentedThanks, and sorry to have to revert this out. Most of your work here will remain committed, its just the plugin and events files which will be removed. I will add them back into #3312200: Paragraph scheduler plugin and re-purpose that issue to add all the paragraph work to-date, so that you can have a working MR and patch if you need it.
I've tested going from rc5 to a branch without the two files mentioned, and the existing paragraphs can be editted without any problem. There are schema errors with missing third-party settings, which I can fix in a hook_update. Yes, like you mentioned it might be worth making it a general function much like
SchedulerManager::entityUpdatewhich could also be called from a drush function. That could be useful in other circumstances too.Comment #21
jonathan1055 commentedFor some unexplained reason I cannot create a new branch on this issue (can on others but not here). Therefore going back to old-school patch file for checking here.
There is no test coverage for the new hook_update, but I have tested it locally, both with the UI and via the new drush command
drush scheduler:entity-revert, starting with a site at Scheduler 2.0.0.rc5, enabling Parahraphs for Scheduler, entering dates, then switching to the new Scheduler branch. All works fine.Comment #23
jonathan1055 commentedNow that the plugin and event files have been removed from 2.x this issue can be closed. The secondary issue #3312200: Paragraph scheduler plugin will become the main one to add the plugin files and solve the remaining bugs.
Comment #24
anfor commentedHi @jonathan1055,
In the hook scheduler_update_8206 the module name isn't correct.
It must be
instead of
I needed to execute the drush command manually to actually delete the fields.
> drush scheduler:entity-revert
Regards,
Comment #25
anybody@anfor please create a separate follow-up issue for that important bug!
Comment #26
anfor commented@Anybody, you are right, I should have created an issue from the get go.
Here we go : https://www.drupal.org/project/scheduler/issues/3317944
Comment #27
jonathan1055 commentedThanks @anfor for reporting that bug. I thoight I had tested it, but I must have got confused between my dev environments and tested on a site which actually did not have Paragraphs enabled anyway.
@Anybody I would have fixed it on this issue, but will now do it on #3317944: Paragraph module machine name in hook_update_N