Skip to content

Rebuild the 5.x baseline for Craft 6 beta - #215

Open
timkelty wants to merge 4 commits into
5.xfrom
craft-6-baseline
Open

timkelty wants to merge 4 commits into
5.xfrom
craft-6-baseline

Conversation

@timkelty

@timkelty timkelty commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Description

This rebuilds 5.x as the baseline that the Craft 6 feature work (disk, transformer, static cache) will build on. As it stands, 5.x can't run queued jobs on Craft Cloud, never connects to Valkey, and has no way to run Craft locally for development.

 namespace
-craft\cloud\…                          (Craft 5 style)
+CraftCms\Cloud\…                       (matches CraftCms\Cms)

 queue function   src/bref/handlers/job-sqs-cmd.php   (path unchanged; infra references it)
-JobSqsHandler → `craft cloud/queue/exec {id}`         (that command doesn't exist on 5.x)
+bref/laravel-bridge QueueHandler, jobs run in-process

 command function src/bref/handlers/command-sqs-cmd.php (path unchanged)
-CraftCliEntrypoint + CurlClient + CommandHandler/command-cmd.php
+Lambda\CommandSqsHandler (Symfony Process + Guzzle); command-cmd.php removed (no infra reference)
+command timeout = the invocation's remaining time, less 5s to post the result

 CloudServiceProvider on Cloud
-Valkey from the CRAFT_CLOUD_CACHE_SRV SRV record     (cloud-api never sets it)
+Valkey from CRAFT_CLOUD_REDIS_URL, with 1s timeouts, in Laravel's failover store
+logging.default = stderr, whatever the project chose
+file/cookie sessions → database
-logging.channels.emergency.path       (fixed upstream in bref/laravel-bridge#203, now ^3.1)

 dependencies
-bref/extra-php-extensions             (serverless.yml layer metadata; Cloud's builder copies extension images itself)
-ext-curl
+guzzlehttp/guzzle

 development
+Orchestra Testbench booting CraftServiceProvider + CloudServiceProvider in tests
+Testbench workbench: `composer serve` runs Craft 6 with this package on SQLite
+.agents/setup + .amp/services.yaml for Amp orbs

Cloud::isCraftCloud() and Cloud::env() are now the one place that reads the function's environment. Values come from the process environment, so they stay right when config is cached.

Releases switch from the unused semantic-release config to release-it, as on 3.x. Semantic-release would have numbered from 3.1.0, the newest tag in this branch's history, and collided with 3.x releases. The first release is tagged by hand as 5.0.0-beta.1.

Infra: Laravel's redis store uses the phpredis extension, which Bref compiles in but disables. Craft 3.x didn't need it because yii2-redis is pure PHP. Cloud's builder has to add extension=redis to the tenant PHP config (cloud-api's craft.php.ini); without it, the failover store skips Valkey and uses the database.

- Move to the CraftCms\Cloud namespace
- Run queued jobs with bref/laravel-bridge's QueueHandler
- Run platform commands with a Guzzle-based CommandSqsHandler
- Give the Valkey connection 1-second timeouts
- Force stderr logging and database sessions on Cloud
- Read CRAFT_CLOUD_* through one Cloud class
- Test with Orchestra Testbench booting Craft
- Release with release-it, matching 3.x

Amp-Thread-ID: https://ampcode.com/threads/T-5e08134f-736d-4bda-8b28-d21654023ef7
Co-authored-by: Amp <amp@ampcode.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-10T18:42:47.813975Z f2c8729 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f2c8729630

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/Lambda/CommandSqsHandler.php Outdated
$response = $this->post($url, $result);
} catch (GuzzleException $e) {
fwrite(STDERR, json_encode($result) . "\n");
$this->post($url, [

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Prevent callback failures from rerunning completed commands

When both callback attempts fail at the transport layer, this second post() throws an uncaught GuzzleException after the Craft command has already completed. The SQS invocation is consequently reported as failed and the message can be delivered again, rerunning arbitrary commands with potentially non-idempotent effects; catch the fallback failure and log it without failing the completed record.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in bad36d5, with a regression test.

Comment thread src/Lambda/CommandSqsHandler.php Outdated
Comment on lines +115 to +116
return $this->client->post($url, [
RequestOptions::JSON => $body,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve command output containing invalid UTF-8

When a command emits non-UTF-8 bytes, Guzzle's JSON request encoding throws instead of sending the result, so the callback receives only a generic request-failure payload and the actual command output is lost. The previous implementation deliberately encoded with JSON_INVALID_UTF8_SUBSTITUTE; apply equivalent sanitization before using the JSON request option.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in bad36d5, with a regression test.

timkelty and others added 3 commits November 10, 2026 18:44
The callback post no longer throws when both attempts fail at the transport
layer, so SQS won't redeliver and rerun a completed command. Output that
isn't valid UTF-8 is substituted instead of failing to encode, as in 3.x.

Amp-Thread-ID: https://ampcode.com/threads/T-5e08134f-736d-4bda-8b28-d21654023ef7
Co-authored-by: Amp <amp@ampcode.com>
The workbench serves a Craft 6 site with this package installed, on SQLite,
from Testbench's skeleton. `composer build` installs Craft and `composer serve`
serves it. In Amp orbs, .agents/setup installs PHP 8.5 and dependencies and
.amp/services.yaml runs the workbench behind a portal.

Also relocks craftcms/cms and craftcms/cms-assets at 6.0.0-beta.1, now that
Packagist has indexed the cms-assets tag.

Amp-Thread-ID: https://ampcode.com/threads/T-5e08134f-736d-4bda-8b28-d21654023ef7
Co-authored-by: Amp <amp@ampcode.com>
- Read CRAFT_CLOUD_REDIS_URL, which is what cloud-api sets. CRAFT_CLOUD_CACHE_SRV
  was never set, so Valkey was never used. This also drops the per-boot DNS lookup.
- Give console commands the invocation's remaining time, less a buffer to send the
  result, instead of assuming a 900-second function timeout.
- Drop bref/extra-php-extensions. It only ships serverless.yml layer metadata, and
  Cloud's builder copies the extension images itself.

Amp-Thread-ID: https://ampcode.com/threads/T-5e08134f-736d-4bda-8b28-d21654023ef7
Co-authored-by: Amp <amp@ampcode.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant