Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade to laravel 8 #26

Merged
merged 45 commits into from
Aug 9, 2021
Merged

upgrade to laravel 8 #26

merged 45 commits into from
Aug 9, 2021

Conversation

tschallacka
Copy link
Contributor

Based on issue:
wintercms/winter#23

All conflicts are resolved, all tests seem to pass without issue.
Some care is needed to review the wintercms implementation for the TransportAdapter as this has changed in Laravel 7 to MailAdapter. The tests pass, but integration may not, but I'm not familiar enough with the mail adapter to make an integration test.

@LukeTowers LukeTowers changed the base branch from wip/1.2 to develop April 25, 2021 19:17
@LukeTowers LukeTowers changed the base branch from develop to wip/1.2 April 25, 2021 19:17
@LukeTowers LukeTowers added this to the v1.2.0 milestone Apr 25, 2021
@tschallacka
Copy link
Contributor Author

Concerning #21 laravel 8 needs yaml 5.1 so the other branch referenced here should aim to optimize for 5.1.

tests/.phpunit.result.cache Outdated Show resolved Hide resolved
tests/Database/QueryBuilderTest.php Show resolved Hide resolved
src/Database/Query/Grammars/PostgresGrammar.php Outdated Show resolved Hide resolved
src/Database/Pivot.php Show resolved Hide resolved
composer.json Outdated Show resolved Hide resolved
composer.json Show resolved Hide resolved
@tschallacka
Copy link
Contributor Author

@mjauvin
Copy link
Member

mjauvin commented May 7, 2021

@tschallacka ok, but I am refering to regular closures provided as an event listener. If the Object which handle the event gets cached (serialized), any closure used as the event handler will currently cause an error when trying to serialize the object.

@tschallacka
Copy link
Contributor Author

Can you provide a unit test code that mimicks that? I'll see if I can do something about that.

@mjauvin
Copy link
Member

mjauvin commented May 7, 2021

@tschallacka you can try this test CMS page:

title = Closure Serialization Test Page 
url = /cache 
== 
function onInit()
{
    \Cms\Classes\Page::extend(function ($model) {
        $model->bindEvent('cms.page.display', function () {});
    });

    $page = new \Cms\Classes\Page([
        'fileName' => 'test-page',
        'title' => 'My Test Page',
        'url' => '/test-page',
    ]);

    Cache::put('my-cached-page-key', $page);
}
==
Hello World!

@tschallacka
Copy link
Contributor Author

What a strange place to extend a model. It should be extended in the boot method of the plugin...

I'll have a look at it though.

@mjauvin
Copy link
Member

mjauvin commented May 7, 2021

You can apply this wherever you want, just a quick way to demonstrate

@mjauvin
Copy link
Member

mjauvin commented May 7, 2021

You can also test this in artisan tinker like this (easiest way):

# php artisan tinker
Psy Shell v0.10.8 (PHP 8.0.5 — cli) by Justin Hileman
>>> class MyTest extends \Model
... {
... }
>>> 
>>> MyTest::extend(function ($model) {
...     $model->bindEvent('cms.page.display', function () {});
... });
=> null
>>> $obj = new MyTest();
=> MyTest {#3787}
>>> Cache::put('my-obj-key', $obj);
Exception with message 'Serialization of 'Closure' is not allowed'
>>> 

If you comment out $model->bindEvent('cms.page.display', function () {}); you won't get the error

@tschallacka
Copy link
Contributor Author

@mjauvin that's a good example I can put in a unit test. Thanks.

Addes serializable protections for emitter and extendable
addes Serialisation helper for wrapping closures
Added constants to get rid of the magic strings in the traits.
@tschallacka
Copy link
Contributor Author

@mjauvin I've added some serialisation protection. Referenced variable connections via use (&$var) get severed during serialisation, but use ($var) persists.

@LukeTowers I've added a lot in the latest commits, see the commit message for a broad overview, if you have any questions just ask.

I still need to check Dispatcher for closures. Are there any other classes that work via closures that need to be serializeable?

replaced code with calls to serialisation helpers
@tschallacka
Copy link
Contributor Author

Should I squash the commits? And apologies for forgetting to run the code quality check.

@LukeTowers
Copy link
Member

Don't worry about squashing the commits, we take care of the history when we merge.

@github-actions
Copy link

This pull request will be closed and archived in 3 days, as there has been no activity in the last 60 days.
If this is still being worked on, please respond and we will re-open this pull request.
If this pull request is critical to your business, consider joining the Premium Support Program where a Service Level Agreement is offered.

@LukeTowers
Copy link
Member

Thanks bot for doing the job you're meant to do :)

I still need to take another look at this, but @bennothommo have you had a look yet?

@bennothommo
Copy link
Member

@LukeTowers not really - was going to take a look when Laravel 9 was out.

@jumbophp
Copy link

jumbophp commented Aug 8, 2021

ok luke ,
where do you think is the problem ? regading this PR ?

@LukeTowers LukeTowers merged commit 04230d5 into wintercms:wip/1.2 Aug 9, 2021
@LukeTowers
Copy link
Member

@lzomedia our main list for tracking progress on this is available here: wintercms/winter#148. This PR is good enough to merge into our WIP branch at the moment though. Thanks @tschallacka for your work on this so far!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants