Laravel 8.73 Released

News

November 23rd, 2021

laravel8.jpg

The Laravel team released 8.73 with support for Countable objects in the string pluralizer, allowing closures for determining cache TTL, a lazyByIdDesc() query builder method, and the latest changes in the v8.x branch.

This post includes a few releases that happened over the last few days, including a revert in 8.73.1, so be sure to update to the latest 8.x version:

Add .phar To Blocked PHP Extensions (8.73)

Stephen Rees-Carter contributed adding the .phar extension to blocked PHP extensions during file upload:

By default Debian includes support for executing .phar files alongside .php and .phtml files, and should be included in the blocked list.

See: https://salsa.debian.org/php-team/php/-/blob/debian/main/7.4/debian/php-cgi.conf#L5-7

This should also be backported into all currently supported versions of Laravel.

Allow a Closure to be Passed as a TTL in Cache remember() method (8.73)

Gerard Nesta contributed the ability to pass a Closure as a TTL in the Cache::remember() method:

1Cache::remember(
2 'count_events_hosted',
3 // Now you can pass a Closure to calculate TTL
4 function () use ($user) {
5 // Expire when closest event ends
6 $closestEventEndsAt = $user->hostedEvents()
7 ->select('ends_at')
8 ->where('starts_at', '>', Date::now())
9 ->orderBy('ends_at')
10 ->limit(1)
11 ->value('ends_at');
12 
13 return $closestEventEndsAt ?
14 Date::parse($closestEventEndsAt) :
15 60;
16 },
17 function () use ($user) {
18 return $user->hostedEvents()->ended()->count();
19 }
20);

Implement lazyByIdDesc in descending order (8.73)

Moshe Brodsky contributed a lazyByIdDesc() method, which queries lazily by chunking the results of a query by comparing IDs in descending order:

1$query->lazyByIdDesc();

This is useful when dealing with a lot of data and you want the "newer" objects processed first.

PasswordReset Method for Reset URL (8.72)

Oliver Kaufmann contributed moving the reset URL generation into a separate method for the PasswordReset notification. Similar to VerifyEmail, this allows users to override the default URL generation logic without overriding the toMail() method.

Add Support for Countables to the Pluralizer (8.72)

Michael Dyrynda added support for countable values to the Str::plural() method. You can now pass anything that passes PHP's is_countable() check that implements Countable as the second parameter of plural:

1// Arrays
2$this->assertSame('users', Str::plural('user', []));
3$this->assertSame('user', Str::plural('user', ['one']));
4$this->assertSame('users', Str::plural('user', ['one', 'two']));
5 
6// Collections
7$this->assertSame('users', Str::plural('user', collect()));
8$this->assertSame('user', Str::plural('user', collect(['one'])));
9$this->assertSame('users', Str::plural('user', collect(['one', 'two'])));

Release Notes

You can see the complete list of new features and updates below and the diff between 8.71.0 and 8.73.1 on GitHub. The following release notes are directly from the changelog:

v8.73.1

Revert

v8.73.0

Added

  • Added .phar to blocked PHP extensions in validator (#39666)
  • Allow a Closure to be passed as a ttl in Cache remember() method (#39678)
  • Added Prohibits validation rule to dependentRules property (#39677)
  • Implement lazyById in descending order (#39646)

Fixed

  • Fixed Illuminate/Auth/Notifications/ResetPassword::toMail() (969f101)
  • Fixed assertSoftDeleted & assertNotSoftDeleted (#39673)

v8.72.0

Added

  • Added extra method in PasswortReset for reset URL to match the structure of VerifyEmail (#39652)
  • Added support for countables to the Illuminate/Support/Pluralizer::plural() (#39641)
  • Allow users to specify options for migrate:fresh for DatabaseMigration trait (#39637)

Fixed

  • Casts $value to the int only when not null in Illuminate/Database/Query/Builder::limit() (#39644)

Changed

  • Use parents to resolve middleware priority in SortedMiddleware (#39647)

Filed in:

Paul Redmond

Full stack web developer. Author of Lumen Programming Guide and Docker for PHP Developers.