(See also issue #12948)
After upgrading to Laravel 5.2.27, @push stack order is reversed when using @include into an extending view :
>>> a.blade.php
a
@stack('me')
>>> b.blade.php
@push('me') b @endpush('me')
>>> c.blade.php
@extends('a')
@include('b')
@push('me') c @endpush('me')
Compiling c.blade.php will produce a c b instead of a b c
As a reminder, issue #12948 fix @push with multiple @extends :
>>> a.blade.php
a
@stack('me')
>>> b.blade.php
@extends('a')
@push('me') b @endpush('me')
>>> c.blade.php
@extends('b')
@push('me') c @endpush('me')
Compiling c.blade.php will correctly produce a b c
This is a comment from @mark86092 on issue #12948 :
@includewill increase renderCount, same as@extendsdoes, renderCount determine the position of each@pushblock. The problem now is complicated. If fix,@pushwith@includeis weird, if no fix,@pushwith@extendsis weird.
Yes, this has a bug fix, Please upgrade to the very latest version, and clear the view cache.
Sorry, but no, this is not fixed... read again, this is not the same issue.
I try with the dev-master (and 5.2.29) branch of laravel/framework, clear the view cache, and the problem is the same : @stack order is reversed with @push and @include into an extending view.
Please, take 5 minutes and try my examples and you will see.
When removing array_reverse from yieldPushContent (Illuminate/View/Factory.php) this will fix this issue but breaks issue #12948.
The difficulty here is to fix this issue without breaking the other one.
@sebastienheyd, it seems not an easy problem. The logic behind @include and @extends is complex, maybe fix it in 5.3 (?)
Anyway, I propose test for these kind of combining bugs #13181
@mark86092 I analyze a little bit how it works and I understand the difficulty. As you say this is complex.
Adding a test is a good idea, thanks for that. Now I can try to find a solution or at least an idea... ;)
Most helpful comment
@mark86092 I analyze a little bit how it works and I understand the difficulty. As you say this is complex.
Adding a test is a good idea, thanks for that. Now I can try to find a solution or at least an idea... ;)