The Laravel team released v13.45.0 with a migration duration on the MigrationEnded event, peak memory usage on the JobAttempted event, batched writes for the database cache store, and security fixes for SVG uploads and trusted proxies:
Migration Duration on the MigrationEnded Event
Jack Bayliss added a duration property to the MigrationEnded event. It holds the number of milliseconds a migration took to run, for both up and down:
use Illuminate\Database\Events\MigrationEnded; use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Log; Event::listen(function (MigrationEnded $event) { if ($event->duration > 60_000) { Log::warning("Migration [{$event->name}] took {$event->duration}ms."); } });
A listener like this can warn you when one migration uses most of a deployment window. Laravel 13.42 added migration failure events, so you can now listen for both slow and failed migrations.
See #62605 for more details.
Peak Memory Usage on the JobAttempted Event
Jack Bayliss also added a memoryUsage property to the JobAttempted event. It holds the worker's peak memory usage in megabytes while it processed the job:
use Illuminate\Queue\Events\JobAttempted; use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Log; Event::listen(function (JobAttempted $event) { Log::info($event->job->resolveName(), [ 'duration' => $event->duration, 'memory' => $event->memoryUsage, ]); });
The queue worker dispatches JobAttempted whether the job succeeds or fails, and it resets PHP's peak memory counter before each job. The value is for one job, not for the lifetime of the worker.
See #62678 for more details.
Batched Writes and Deletes for the Database Cache Store
Rias changed the database cache store so that putMany() without a TTL and deleteMultiple() no longer run one query per key. Laravel now writes or deletes 250 keys per query:
// 600 keys: 3 queries instead of 600 Cache::store('database')->putMany($values); Cache::store('database')->deleteMultiple($keys);
The chunk size keeps each query under the 2,100 bound parameter limit on SQL Server. In the pull request, writing 3,000 keys on SQL Server 2022 went from 3,514 ms to 146 ms. This follows the Redis pipelining change in Laravel 13.44.
See #62626 for more details.
The dimensions Rule Requires SVG to Be Allowed Explicitly
Mior Muhammad Zaki changed how the dimensions validation rule handles SVG files. Before this release, the rule passed any SVG upload without checking it, so a field validated with only dimensions accepted an SVG that contained JavaScript.
An SVG now passes dimensions only when another rule on the same attribute allows SVG:
// Fails for an SVG upload 'avatar' => ['dimensions:max_width=1000'], // Passes for an SVG upload 'avatar' => ['image:allow_svg', 'dimensions:max_width=1000'], 'avatar' => ['mimes:png,jpg,svg', 'dimensions:max_width=1000'],
This is a behavior change. If your application accepts SVG uploads on a field that uses dimensions, check that the field also has image:allow_svg, a mimes rule that includes svg, or a mimetypes rule that includes image/svg+xml.
See #62716 for more details.
Wildcard Trusted Proxies Trust Only the Calling Proxy
Mior Muhammad Zaki reverted an earlier change to trustProxies(at: '*'). That change made the wildcard trust every address in the X-Forwarded-For header, so the left-most entry, which the client can set, became the client IP. An application that used the wildcard could have its client IP spoofed.
->withMiddleware(function (Middleware $middleware) { $middleware->trustProxies(at: '*'); })
With this release, the wildcard trusts only the proxy that calls your server (REMOTE_ADDR), as it did in v13.19.0.
See #62702 for more details.
Prerender Requests in Request::prefetch()
Emaia updated Request::prefetch() to recognize prerender requests. Chrome sends Sec-Purpose: prefetch;prerender for pages prerendered through the Speculation Rules API, and the method only matched the exact value prefetch:
// Sec-Purpose: prefetch;prerender $request->prefetch(); // true (was false)
Laravel's session middleware uses this check to keep prefetched URLs out of the session's previous URL. Without the fix, back() could redirect to a prerendered page the user never opened.
See #62665 for more details.
Release Notes
You can see the complete list of new features and updates below and the diff between 13.44.0 and 13.45.0 on GitHub.
v13.45.0
- [12.x] Skip mocked database manager when disconnecting connections on teardown by @randyclassen in #62624
- [12.x] Send scheduled task output to the Laravel Cloud log socket by @jradtilbrook in #62612
- [13.x] fix: notification tests returning strings from
via()method by @Roardom in #62646 - [13.x] Resolve the context repository from the container in the process concurrency driver by @pawell67 in #62645
- [13.x] Speed up initialization in
DatabaseTruncationby @KentarouTakeda in #62647 - [13.x] Ignore nested array input in FormRequest models() by @bsulyan in #62631
- [12.x] Fix TypeError in date comparison rules on non-date values by @GrahamCampbell in #62630
- [12.x] Fix TypeError in validation rules on non-string values by @GrahamCampbell in #62629
- [12.x] Validate MAC across all decryption keys by @GrahamCampbell in #62628
- [13.x] Avoid unserializing closure twice by @rodrigopedra in #62627
- [13.x] add duration to MigrationEnded by @jackbayliss in #62605
- [13.x] Batch database cache writes and deletes by @riasvdv in #62626
- [13.x] add peak memory usage to JobAttempted by @jackbayliss in #62678
- [13.x] Respect subdomains option in trustHosts() when no hosts are given by @crynobone in #62677
- [12.x] Use the line log formatter during the Cloud build and deploy phase by @avosalmon in #62673
- [12.x] Improve consistency and performance of distinct validation rule by @pushpak1300 in #62667
- [12.x] Speed up wildcard attribute lookups during validation by @pushpak1300 in #62668
- [13.x] Improve consistency and performance of distinct validation rule by @pushpak1300 in #62666
- [13.x] Recognize prerender requests in Request::prefetch() by @emaia in #62665
- [13.x] Fix response compatibility with Symfony 8.2 by @crynobone in #62654
- [13.x] Adjust ClearResetsCommand info output by @jackbayliss in #62657
- [13.x] Compare scalar values strictly in JSON Schema MatchesEnum rule by @bsulyan in #62656
- [13.x] Remove Mockery from
PendingCommandby @jasonmccreary in #62669 - [13.x] Don't capture the base application in ApplicationBuilder console / schedule callbacks by @terrylinooo in #62684
- [12.x] Fix
not_inrule accepting numerically equal values and arrays by @crynobone in #62703 - [13.x] Fix
doesnt_containrule accepting typed values by @crynobone in #62704 - [13.x] Revert wildcard TrustProxies trusting all addresses by @crynobone in #62702
- [13.x] Make Request::isJson() case-insensitive by @natsuki-engr in #62701
- Merge branch '12.x' into 13.x by @crynobone in #62719
- [13.x] Require SVG to be explicitly allowed for the dimensions rule by @crynobone in #62716
- [13.x] Parse backslashes in the URI authority like browsers by @crynobone in #62718
- [13.x] Add false to PhpRedisConnection::transaction() return type by @MimssoWin in #62711
- [13.x] Fix incorrect read replica details in query exceptions by @omaresmael in #62710
- [13.x] Use display width when aligning route:list output by @Tomoya185-miyawaki in #62709