Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
This is a followup of #2625572: Admin setting 'Enable content type for scheduler' is ignored.
Currently when publishing or unpublishing nodes through the Scheduler API we are first retrieving all eligible nodes through an entity query, and then filtering out the node types that do not have scheduling enabled. We could improve this by adding a condition to the query to only include node types enabled for the action being processed.
Comment | File | Size | Author |
---|---|---|---|
#11 | 2659824.interdiff-10-to-11.txt | 3.42 KB | jonathan1055 |
#11 | 2659824-11.exclude_node_types.patch | 3.63 KB | jonathan1055 |
|
Comments
Comment #2
jonathan1055 CreditAttribution: jonathan1055 commentedThis is a good idea, thanks Pieter for creating this issue. It makes more sense to eliminate the nodes at the start, not have to filter them later.
When changing the queries we should also take the oportunity to use the condition
->exists('publish_on')
instead of->condition('publish_on', 0, '>')
as thid is safer and more generic. The test for greater than zero was left over from previous releases where we stored empty dates as 0, when they should have been null.Secondly, we should order the nodes in a pre-determined sequence so that repeated testing gives the same expected order. I suggest we order by date then by node id, ie
Comment #3
legovaerAdded the changes as suggested in #2
Comment #5
legovaerForgot to perform a diff against the 8.x-1.x branch.
Comment #6
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedYes, those additions are good, but you have forgotten the actual, original reason for this issue:
This issue was created so that we eliminate the nodes at the start. It is just a minor efficiency improvment. I guess the way to do this is to create an array of all enabled node types and add that as a condition.
The tests currently pass because for safety we throw the exceptions, as you can see if you run locally with verbose debug, as I added a call to the dblog page.
Comment #7
mr.baileysI created a helper function to retrieve the node types that have scheduler enabled (meaning the node_type has the publish_on and/or unpublish_on set to true in the third party settings), so they result of that function can be used in the entity query. If necessary, we can split it out even further (when unpublishing, only select the node types where unpublish_on is set, regardless of publish_on).
Comment #9
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedHey, thanks for doing this. First thing I noticed is a typo in SchedulerManager.php
That may well explain many if not all of the test failures.
Comment #10
mr.baileysYes, I copied the changes from #5 manually and it shows... Let's try again.
Comment #11
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedThat's good.
This is easy, and we might as well do it, to make the query return only the node types applicable. I passed parameter
$action
into the new function scheduler_get_scheduler_enabled_node_types thenuse ($action)
to make it available in the callback function. For consistency with the rest of the module, I also changed the defaultFALSE
to$config->get('default_' . $action . '_enable')
as we do not hard-code the defaults anymore (see #2633870: Revisit defaults for third party settings and #2682579: Move constants out of global space into settings and schema)Comment #13
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedSomething is odd. The test failures #11 above do not happen in my local environment, and as far as I can see they are unrelated to the code changes in this patch. They are however, exactly the same set of failures as in #2756147-2: Remove @file tag docblock from .php files where the class matches the filename which I could not understand either.
Also the failures did not alter the status from 'needs review' to 'needs work', the status remains unchanged. Maybe there is something up with the testbots?
Comment #14
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedOK, I can replicate these failures locally, having downloaded the lastest dev of D8.2 - It looks like something has changed between the passes in #10 on June 24 and the fails at #11 on June 28. More investigation required.
Comment #15
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedI have created #2757625: Previously passing tests now fail in Drupal 8.2 - Change assertRaw to assertText to deal with this problem.
Comment #16
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedI have fixed #2757625: Previously passing tests now fail in Drupal 8.2 - Change assertRaw to assertText and requeued the patch in #11 above. All seems fine again.
@mr.baileys are you OK with my changes, shown in the interdiff 10 to 11?
Comment #18
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedThanks @mr.baileys for this. I assume you are OK with my changes interdiff 10 to 11 but if you spot something tell me.