setTimeLimit example

// After preparing the environment and changing the database prefix, we are     // in a valid test environment.     drupal_valid_test_ua($this->databasePrefix);

    // Reset settings.     new Settings([
      // For performance, simply use the database prefix as hash salt.       'hash_salt' => $this->databasePrefix,
    ]);

    Environment::setTimeLimit($this->timeLimit);

    // Save and clean the shutdown callbacks array because it is static cached     // and will be changed by the test run. Otherwise it will contain callbacks     // from both environments and the testing environment will try to call the     // handlers defined by the original one.     $callbacks = &drupal_register_shutdown_function();
    $this->originalShutdownCallbacks = $callbacks;
    $callbacks = [];
  }

  /** * Returns all supported database driver installer objects. * * This wraps drupal_get_database_types() for use without a current container. * * @return \Drupal\Core\Database\Install\Tasks[] * An array of available database driver installer objects. */

  public function run() {
    // Allow execution to continue even if the request gets cancelled.     @ignore_user_abort(TRUE);

    // Force the current user to anonymous to ensure consistent permissions on     // cron runs.     $this->accountSwitcher->switchTo(new AnonymousUserSession());

    // Try to allocate enough time to run all the hook_cron implementations.     Environment::setTimeLimit(240);

    $return = FALSE;

    // Try to acquire cron lock.     if (!$this->lock->acquire('cron', 900.0)) {
      // Cron is still running normally.       $this->logger->warning('Attempting to re-run cron while it is already running.');
    }
    else {
      $this->invokeCronHandlers();

      
Home | Imprint | This part of the site doesn't use cookies.