Skip to content
Snippets Groups Projects
Commit d06dfb35 authored by catch's avatar catch
Browse files

Issue #1875020 by longwave, David_Rothstein, slip, alexpott, catch,...

Issue #1875020 by longwave, David_Rothstein, slip, alexpott, catch, smustgrave, jhodgdon: Cron queue gets processed every time cron is called, regardless of whether it's already being processed elsewhere
parent 9d296187
No related branches found
No related tags found
32 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!54479.5.x SF update,!5014Issue #3071143: Table Render Array Example Is Incorrect,!4868Issue #1428520: Improve menu parent link selection,!4289Issue #1344552 by marcingy, Niklas Fiekas, Ravi.J, aleevas, Eduardo Morales...,!4114Issue #2707291: Disable body-level scrolling when a dialog is open as a modal,!4100Issue #3249600: Add support for PHP 8.1 Enums as allowed values for list_* data types,!3630Issue #2815301 by Chi, DanielVeza, kostyashupenko, smustgrave: Allow to create...,!3600Issue #3344629: Passing null to parameter #1 ($haystack) of type string is deprecated,!3291Issue #3336463: Rewrite rules for gzipped CSS and JavaScript aggregates never match,!2378Issue #2875033: Optimize joins and table selection in SQL entity query implementation,!2334Issue #3228209: Add hasRole() method to AccountInterface,!2074Issue #2707689: NodeForm::actions() checks for delete access on new entities,!2062Issue #3246454: Add weekly granularity to views date sort,!1591Issue #3199697: Add JSON:API Translation experimental module,!1484Exposed filters get values from URL when Ajax is on,!1255Issue #3238922: Refactor (if feasible) uses of the jQuery serialize function to use vanillaJS,!1162Issue #3100350: Unable to save '/' root path alias,!1105Issue #3025039: New non translatable field on translatable content throws error,!1073issue #3191727: Focus states on mobile second level navigation items fixed,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!957Added throwing of InvalidPluginDefinitionException from getDefinition().,!925Issue #2339235: Remove taxonomy hard dependency on node module,!877Issue #2708101: Default value for link text is not saved,!872Draft: Issue #3221319: Race condition when creating menu links and editing content deletes menu links,!844Resolve #3036010 "Updaters",!617Issue #3043725: Provide a Entity Handler for user cancelation,!579Issue #2230909: Simple decimals fail to pass validation,!560Move callback classRemove outside of the loop,!555Issue #3202493,!485Sets the autocomplete attribute for username/password input field on login form.,!30Issue #3182188: Updates composer usage to point at ./vendor/bin/composer
......@@ -134,6 +134,10 @@ public function run() {
}
else {
$this->invokeCronHandlers();
// Process cron queues.
$this->processQueues();
$this->setCronLastTime();
// Release cron lock.
......@@ -143,9 +147,6 @@ public function run() {
$return = TRUE;
}
// Process cron queues.
$this->processQueues();
// Restore the user.
$this->accountSwitcher->switchBack();
......
......@@ -2,6 +2,8 @@
namespace Drupal\Tests\Core;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Config\ImmutableConfig;
use Drupal\Core\Cron;
use Drupal\Core\KeyValueStore\KeyValueMemoryFactory;
use Drupal\Core\Queue\DelayedRequeueException;
......@@ -64,14 +66,8 @@ protected function setUp(): void {
// Create a mock logger to set a flag in the resulting state.
$logger = $this->prophesize('Drupal\Core\Logger\LoggerChannelInterface');
// Safely ignore the cron re-run message when failing to acquire a lock.
//
// We don't need to run regular cron tasks, and we're still implicitly
// testing that queues are being processed.
//
// This argument will need to be updated to match the message text in
// Drupal\Core\Cron::run() should the original text ever be updated.
$logger->warning(Argument::exact('Attempting to re-run cron while it is already running.'))->shouldBeCalled();
// Safely ignore the cron success message.
$logger->info('Cron run completed.')->shouldBeCalled();
// Set a flag to track when a message is logged by adding a callback
// function for each logging method.
foreach (get_class_methods(LoggerInterface::class) as $logger_method) {
......@@ -87,11 +83,18 @@ protected function setUp(): void {
// Create a mock time service.
$time = $this->prophesize('Drupal\Component\Datetime\TimeInterface');
// Create a mock config factory and config object.
$config_factory = $this->prophesize(ConfigFactoryInterface::class);
$config = $this->prophesize(ImmutableConfig::class);
$config->get('logging')->willReturn(FALSE);
$config_factory->get('system.cron')->willReturn($config->reveal());
// Build the container using the resulting mock objects.
\Drupal::setContainer(new ContainerBuilder());
\Drupal::getContainer()->set('logger.factory', $logger_factory->reveal());
\Drupal::getContainer()->set('datetime.time', $time->reveal());
\Drupal::getContainer()->set('state', $this->state);
\Drupal::getContainer()->set('config.factory', $config_factory->reveal());
// Create mock objects for constructing the Cron class.
$module_handler = $this->prophesize('Drupal\Core\Extension\ModuleHandlerInterface');
......@@ -99,11 +102,9 @@ protected function setUp(): void {
$queue_worker_manager = $this->prophesize('Drupal\Core\Queue\QueueWorkerManagerInterface');
$state = $this->prophesize('Drupal\Core\State\StateInterface');
$account_switcher = $this->prophesize('Drupal\Core\Session\AccountSwitcherInterface');
// Create a lock that will always fail when attempting to acquire; we're
// only interested in testing ::processQueues(), not the other stuff.
$lock_backend = $this->prophesize('Drupal\Core\Lock\LockBackendInterface');
$lock_backend->acquire(Argument::exact('cron'), Argument::cetera())->willReturn(FALSE);
$lock_backend->acquire('cron', Argument::cetera())->willReturn(TRUE);
$lock_backend->release('cron')->shouldBeCalled();
// Create a queue worker definition for testing purposes.
$queue_worker = $this->randomMachineName();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment