Skip to content

Commit

Permalink
So queue! (resolves #1910 and #855)
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Aug 14, 2017
1 parent b968a01 commit 8f5a333
Show file tree
Hide file tree
Showing 46 changed files with 779 additions and 2,991 deletions.
26 changes: 26 additions & 0 deletions CHANGELOG-v3.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,29 @@ Craft CMS 3.0 Working Changelog
## Unreleased

### Added
- Craft’s tasks implementation has been replaced with a queue, based on the [Yii 2 Queue Extension](https://github.com/yiisoft/yii2-queue). ([#1910](https://github.com/craftcms/cms/issues/1910))
- The “Failed” message in the queue HUD in the Control Panel now shows the full error message as alt text. ([#855](https://github.com/craftcms/cms/issues/855))
- Added the `instance of()` Twig test.
- Added `craft\base\FlysystemVolume`, which replaces `craft\base\Volume` as the new base class for Flysystem-based volumes.
- Added `craft\behaviors\SessionBehavior`, making it possible for `config/app.php` to customize the base `session` component while retaining Craft’s custom session methods.
- Added `craft\controllers\QueueController`.
- Added `craft\queue\BaseJob`, a base class for queue jobs that adds support for descriptions and progress.
- Added `craft\queue\Command`, which provides `queue/run`, `queue/listen`, and `queue/info` console commands.
- Added `craft\queue\InfoAction`.
- Added `craft\queue\JobInterface`, an interface for queue jobs that want to support descriptions and progress.
- Added `craft\queue\jobs\DeleteStaleTemplateCaches`, replacing `craft\tasks\DeleteStaleTemplateCaches`.
- Added `craft\queue\FindAndReplace`, replacing `craft\tasks\FindAndReplace`.
- Added `craft\queue\GeneratePendingTransforms`, replacing `craft\tasks\GeneratePendingTransforms`.
- Added `craft\queue\LocalizeRelations`, replacing `craft\tasks\LocalizeRelations`.
- Added `craft\queue\UpdateElementSlugsAndUris`, replacing `craft\tasks\UpdateElementSlugsAndUris`.
- Added `craft\queue\Queue`, a built-in queue driver.
- Added `craft\queue\QueueInterface`, an interface for queue drivers that want to support the queue UI in the Control Panel.
- Added `craft\services\Composer::getJsonPath()`.
- Added `craft\services\Volumes::getVolumeByHandle()`.

### Changed
- Renamed the `runTasksAutomatically` config setting to `runQueueAutomatically`.
- Logs that occur during `queue` requests now get saved in `storage/logs/queue.log`.
- The updater now ensures it can find `composer.json` before putting the system in Maintenance Mode, reducing the liklihood that Craft will mistakingly think that it’s already mid-update later on. ([#1883](https://github.com/craftcms/cms/issues/1883))
- The updater now ensures that the `COMPOSER_HOME`, `HOME` (\*nix), or `APPDATA` (Windows) environment variable is set before putting the system in Maintenance Mode, reducing the liklihood that Craft will mistakingly think that it’s already mid-update later on. ([#1890](https://github.com/craftcms/cms/issues/1890#issuecomment-319715460))
- `craft\mail\Mailer::send()` now processes Twig code in the email message before parsing it as Markdown, if the message was composed via `craft\mail\Mailer::composeFromKey()`. ([#1895](https://github.com/craftcms/cms/pull/1895))
Expand All @@ -24,9 +40,19 @@ Craft CMS 3.0 Working Changelog
- Looping through element queries directly is now deprecated. Use the `all()` function to fetch the query results before looping over them. ([#1902](https://github.com/craftcms/cms/issues/1902))

### Removed
- Removed `craft\base\Task`.
- Removed `craft\base\TaskInterface`.
- Removed `craft\base\TaskTrait`.
- Removed `craft\controllers\TasksController`.
- Removed `craft\db\TaskQuery`.
- Removed `craft\events\MailFailureEvent`.
- Removed `craft\events\TaskEvent`.
- Removed `craft\mail\Mailer::EVENT_SEND_MAIL_FAILURE`.
- Removed `craft\records\Task`.
- Removed `craft\services\Tasks`.
- Removed `craft\tasks\ResaveAllElements`.
- Removed `craft\web\Request::getQueryParamsWithoutPath()`.
- Removed `craft\web\twig\variables\Tasks`, which provided the deprecated `craft.tasks` template variable.

### Fixed
- Fixed a migration error that could occur if `composer.json` didn’t have any custom `repositories` defined.
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"yiisoft/yii2": "~2.0.12.0",
"yiisoft/yii2-debug": "2.0.8",
"yiisoft/yii2-swiftmailer": "~2.0.6",
"yiisoft/yii2-queue": "~2.0.0",
"zendframework/zend-feed": "~2.8.0"
},
"require-dev": {
Expand Down
26 changes: 14 additions & 12 deletions src/base/ApplicationTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@
use craft\i18n\I18N;
use craft\i18n\Locale;
use craft\models\Info;
use craft\queue\QueueInterface;
use craft\services\Security;
use craft\web\Application as WebApplication;
use craft\web\AssetManager;
use craft\web\View;
use yii\mutex\FileMutex;
use yii\queue\db\Queue;
use yii\web\BadRequestHttpException;
use yii\web\ServerErrorHttpException;

Expand Down Expand Up @@ -69,6 +71,7 @@
* @property \craft\db\MigrationManager $migrator The application’s migration manager
* @property \craft\services\Path $path The path service
* @property \craft\services\Plugins $plugins The plugins service
* @property Queue|QueueInterface $queue The job queue
* @property \craft\services\Relations $relations The relations service
* @property \craft\services\Resources $resources The resources service
* @property \craft\services\Routes $routes The routes service
Expand All @@ -80,7 +83,6 @@
* @property \craft\services\SystemMessages $systemMessages The system email messages service
* @property \craft\services\SystemSettings $systemSettings The system settings service
* @property \craft\services\Tags $tags The tags service
* @property \craft\services\Tasks $tasks The tasks service
* @property \craft\services\TemplateCaches $templateCaches The template caches service
* @property \craft\services\Tokens $tokens The tokens service
* @property \craft\services\Updates $updates The updates service
Expand Down Expand Up @@ -951,6 +953,17 @@ public function getPlugins()
return $this->get('plugins');
}

/**
* Returns the queue service.
*
* @return Queue|QueueInterface The queue service
*/
public function getQueue()
{
/** @var WebApplication|ConsoleApplication $this */
return $this->get('queue');
}

/**
* Returns the relations service.
*
Expand Down Expand Up @@ -1050,17 +1063,6 @@ public function getTags()
return $this->get('tags');
}

/**
* Returns the tasks service.
*
* @return \craft\services\Tasks The tasks service
*/
public function getTasks()
{
/** @var WebApplication|ConsoleApplication $this */
return $this->get('tasks');
}

/**
* Returns the template cache service.
*
Expand Down
135 changes: 0 additions & 135 deletions src/base/Task.php

This file was deleted.

45 changes: 0 additions & 45 deletions src/base/TaskInterface.php

This file was deleted.

50 changes: 0 additions & 50 deletions src/base/TaskTrait.php

This file was deleted.

7 changes: 3 additions & 4 deletions src/config/GeneralConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -557,15 +557,14 @@ class GeneralConfig extends Object
*/
public $rotateImagesOnUploadByExifData = true;
/**
* @var bool Whether Craft should run pending background tasks automatically over HTTP requests, or leave it up to something
* like a Cron job to call index.php/actions/tasks/runPendingTasks at a regular interval.
* @var bool Whether Craft should run pending queue jobs automatically over HTTP requests.
*
* This setting should be disabled for servers running Win32, or with Apache’s mod_deflate/mod_gzip installed,
* where PHP’s [flush()](http://php.net/manual/en/function.flush.php) method won’t work.
*
* If disabled, an alternate task running trigger *must* be set up separately.
* If disabled, an alternate queue runner *must* be set up separately.
*/
public $runTasksAutomatically = true;
public $runQueueAutomatically = true;
/**
* @var bool Whether Craft should sanitize uploaded SVG files and strip out potential malicious looking content.
*
Expand Down
3 changes: 3 additions & 0 deletions src/config/app/console.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php

return [
'bootstrap' => [
'queue',
],
'components' => [
'request' => craft\console\Request::class,
'user' => craft\console\User::class,
Expand Down
Loading

1 comment on commit 8f5a333

@michaelrog
Copy link

@michaelrog michaelrog commented on 8f5a333 Aug 14, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow. 🎉 much diffs, very excite. 👍🏼👍🏼

Please sign in to comment.