Skip to content

Conversation

nunomaduro
Copy link
Member

@nunomaduro nunomaduro commented Sep 13, 2021

This pull request adds PHP 8.1 support to serializable closures by replacing opis/closure by laravel/serializable-closure.

  • We decided to fork the opis package as the upcoming version 4.x is a complete rewrite on top of the FFI extension. As Laravel is a web framework, and FFI is not enabled by default in web requests (and some OS's), this fork allows us to keep using the 3.x series while adding support for new PHP versions - including PHP 8.1.
  • Queued jobs, and cached routes, that were serialized with opis/closure will still work, as the package and the code still exists in Laravel 8.x. Yet, the package opis/closure is scheduled for removal in Laravel 9.x. By then, normally people no longer have queued jobs, and cached routes, using the old format. Of course, every new queued jobs, and cached routes, will be using laravel/serializable-closure for serialization.
  • Small caveat: Queued jobs, and cached routes, that used opis/closure for their serialized string formats won't work with PHP 8.1. Therefore, people need to ensure that all queued jobs, and cached routes, are already using the new laravel/serializable-closure before migrating to PHP 8.1. One idea to speed up the process is having this pull request targeting 8.x branch, instead of php81-fixes.

Remaining tasks before merging this pull request:

nunomaduro and others added 2 commits September 14, 2021 10:19
Co-authored-by: Dries Vints <dries@vints.io>
@nunomaduro nunomaduro marked this pull request as ready for review September 14, 2021 12:14
@nunomaduro nunomaduro changed the title Adds PHP 8.1 support to serializable closures [8.x] Adds PHP 8.1 support to serializable closures Sep 14, 2021
Copy link
Collaborator

@GrahamCampbell GrahamCampbell left a comment

Choose a reason for hiding this comment

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

👍 assuming this has been tested on a real app. :)

@taylorotwell taylorotwell merged commit 15c4052 into php81-fixes Sep 14, 2021
@taylorotwell taylorotwell deleted the feat/php81-serializable-closure branch September 14, 2021 13:29
taylorotwell added a commit that referenced this pull request Sep 15, 2021
* Add ReturnTypeWillChange to SessionHandlerInterface usages

* Bump commonmark

* Fix getIterator

* Use Symfony 5.4 components

* Dev mockery

* Mimic PHP 8.0

* Try removing symfony components

* Mockery

* Fix type errors in db tests (#38696)

* Fix type errors in db tests

* Apply fixes from StyleCI

Co-authored-by: Taylor Otwell <taylorotwell@users.noreply.github.com>

* Additional DB test fixes (#38699)

* More DB fixes (#38700)

* PHP 8.1 prefer-lowest builds

* Remove skipping PHP 8.1 builds

* Bump PHPUnit

* Revert "PHP 8.1 prefer-lowest builds"

This reverts commit d5b01d2.

* [8.x] Adds PHP 8.1 support to serializable closures (#38801)

* Makes serializable closures work with PHP 8.1

* Apply fixes from StyleCI

* Fixes PHP 7.3 tests

* Refactors

* Updates deprecated warning

Co-authored-by: Dries Vints <dries@vints.io>

* Fixes restoring properties

* Update QueueServiceProvider.php

Co-authored-by: Taylor Otwell <taylorotwell@users.noreply.github.com>
Co-authored-by: Dries Vints <dries@vints.io>
Co-authored-by: Taylor Otwell <taylor@laravel.com>

* Fix default value

* Fix mb_strlen value

* Adds `continue-on-error` for PHP 8.1

* [8.x] Add explicit `@return` annotations in `{@inheritdoc}` from vendors and add some missing `#[\ReturnTypeWillChange]` (#38819)

* Add explicit `@return` to `{@inheritdoc}` PHPDoc

* Use `return null;` when the return type is `null`

* Skips PHP 8.1 failing tests

* Skips some more PHP 8.1 related tests

* Skips some more PHP 8.1 related tests

* Skips some more PHP 8.1 related tests

* Skips some more PHP 8.1 related tests

* Skips some more PHP 8.1 related tests

* Skips some more PHP 8.1 related tests

* Skips some more PHP 8.1 related tests

* Update SerializableClosure.php

Co-authored-by: Graham Campbell <GrahamCampbell@users.noreply.github.com>
Co-authored-by: Taylor Otwell <taylorotwell@users.noreply.github.com>
Co-authored-by: Nuno Maduro <enunomaduro@gmail.com>
Co-authored-by: Taylor Otwell <taylor@laravel.com>
Co-authored-by: Wouter J <wouterj@users.noreply.github.com>
@agustinprod
Copy link
Contributor

agustinprod commented Oct 6, 2021

We're seeing some exceptions thrown on our queues, because both of the libraries are trying to register the same stream protocol:

stream_wrapper_register(): Protocol closure:// is already defined.

opis/closure author says he gained the right to dont check if it's in use:
opis/closure#106

Maybe laravel/serializable-closure should register a different protocol name

@nunomaduro
Copy link
Member Author

Please create a new issue on the serializable closure repository.

victorvilella pushed a commit to cdsistemas/framework that referenced this pull request Oct 12, 2021
* Add ReturnTypeWillChange to SessionHandlerInterface usages

* Bump commonmark

* Fix getIterator

* Use Symfony 5.4 components

* Dev mockery

* Mimic PHP 8.0

* Try removing symfony components

* Mockery

* Fix type errors in db tests (laravel#38696)

* Fix type errors in db tests

* Apply fixes from StyleCI

Co-authored-by: Taylor Otwell <taylorotwell@users.noreply.github.com>

* Additional DB test fixes (laravel#38699)

* More DB fixes (laravel#38700)

* PHP 8.1 prefer-lowest builds

* Remove skipping PHP 8.1 builds

* Bump PHPUnit

* Revert "PHP 8.1 prefer-lowest builds"

This reverts commit d5b01d2.

* [8.x] Adds PHP 8.1 support to serializable closures (laravel#38801)

* Makes serializable closures work with PHP 8.1

* Apply fixes from StyleCI

* Fixes PHP 7.3 tests

* Refactors

* Updates deprecated warning

Co-authored-by: Dries Vints <dries@vints.io>

* Fixes restoring properties

* Update QueueServiceProvider.php

Co-authored-by: Taylor Otwell <taylorotwell@users.noreply.github.com>
Co-authored-by: Dries Vints <dries@vints.io>
Co-authored-by: Taylor Otwell <taylor@laravel.com>

* Fix default value

* Fix mb_strlen value

* Adds `continue-on-error` for PHP 8.1

* [8.x] Add explicit `@return` annotations in `{@inheritdoc}` from vendors and add some missing `#[\ReturnTypeWillChange]` (laravel#38819)

* Add explicit `@return` to `{@inheritdoc}` PHPDoc

* Use `return null;` when the return type is `null`

* Skips PHP 8.1 failing tests

* Skips some more PHP 8.1 related tests

* Skips some more PHP 8.1 related tests

* Skips some more PHP 8.1 related tests

* Skips some more PHP 8.1 related tests

* Skips some more PHP 8.1 related tests

* Skips some more PHP 8.1 related tests

* Skips some more PHP 8.1 related tests

* Update SerializableClosure.php

Co-authored-by: Graham Campbell <GrahamCampbell@users.noreply.github.com>
Co-authored-by: Taylor Otwell <taylorotwell@users.noreply.github.com>
Co-authored-by: Nuno Maduro <enunomaduro@gmail.com>
Co-authored-by: Taylor Otwell <taylor@laravel.com>
Co-authored-by: Wouter J <wouterj@users.noreply.github.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.

5 participants