Skip to content

Commit 0d2bec8

Browse files
committed
Merge branch '6.x' into 8.x
# Conflicts: # .styleci.yml # src/Illuminate/Foundation/Application.php # src/Illuminate/View/Concerns/ManagesLayouts.php # tests/Database/DatabaseSqlServerSchemaGrammarTest.php # tests/View/ViewBladeCompilerTest.php
2 parents d5e66ba + 29f3df4 commit 0d2bec8

File tree

7 files changed

+59
-19
lines changed

7 files changed

+59
-19
lines changed

CHANGELOG-6.x.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# Release Notes for 6.x
22

3-
## [Unreleased](https://github.com/laravel/framework/compare/v6.20.40...6.x)
3+
## [Unreleased](https://github.com/laravel/framework/compare/v6.20.41...6.x)
4+
5+
6+
## [v6.20.41 (2021-11-23)](https://github.com/laravel/framework/compare/v6.20.40...v6.20.41)
7+
8+
### Added
9+
- Added phar to list of shouldBlockPhpUpload() in validator ([2d1f76a](https://github.com/laravel/framework/commit/2d1f76ab752ced011da05cf139799eab2a36ef90))
410

511

612
## [v6.20.40 (2021-11-17)](https://github.com/laravel/framework/compare/v6.20.39...v6.20.40)

src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ public function compileDropDefaultConstraint(Blueprint $blueprint, Fluent $comma
239239

240240
$sql = "DECLARE @sql NVARCHAR(MAX) = '';";
241241
$sql .= "SELECT @sql += 'ALTER TABLE [dbo].[{$tableName}] DROP CONSTRAINT ' + OBJECT_NAME([default_object_id]) + ';' ";
242-
$sql .= 'FROM SYS.COLUMNS ';
242+
$sql .= 'FROM sys.columns ';
243243
$sql .= "WHERE [object_id] = OBJECT_ID('[dbo].[{$tableName}]') AND [name] in ({$columns}) AND [default_object_id] <> 0;";
244244
$sql .= 'EXEC(@sql)';
245245

src/Illuminate/View/Compilers/Compiler.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function __construct(Filesystem $files, $cachePath)
4848
*/
4949
public function getCompiledPath($path)
5050
{
51-
return $this->cachePath.'/'.sha1($path).'.php';
51+
return $this->cachePath.'/'.sha1('v2'.$path).'.php';
5252
}
5353

5454
/**

src/Illuminate/View/Compilers/Concerns/CompilesLayouts.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
namespace Illuminate\View\Compilers\Concerns;
44

5-
use Illuminate\View\Factory as ViewFactory;
6-
75
trait CompilesLayouts
86
{
97
/**
@@ -67,7 +65,9 @@ protected function compileSection($expression)
6765
*/
6866
protected function compileParent()
6967
{
70-
return ViewFactory::parentPlaceholder($this->lastSection ?: '');
68+
$escapedLastSection = strtr($this->lastSection, ['\\' => '\\\\', "'" => "\\'"]);
69+
70+
return "<?php echo \Illuminate\View\Factory::parentPlaceholder('{$escapedLastSection}'); ?>";
7171
}
7272

7373
/**

src/Illuminate/View/Concerns/ManagesLayouts.php

+26-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Illuminate\View\Concerns;
44

55
use Illuminate\Contracts\View\View;
6+
use Illuminate\Support\Str;
67
use InvalidArgumentException;
78

89
trait ManagesLayouts
@@ -28,6 +29,13 @@ trait ManagesLayouts
2829
*/
2930
protected static $parentPlaceholder = [];
3031

32+
/**
33+
* The parent placeholder salt for the request.
34+
*
35+
* @var string
36+
*/
37+
protected static $parentPlaceholderSalt;
38+
3139
/**
3240
* Start injecting content into a section.
3341
*
@@ -168,14 +176,30 @@ public function yieldContent($section, $default = '')
168176
public static function parentPlaceholder($section = '')
169177
{
170178
if (! isset(static::$parentPlaceholder[$section])) {
171-
static::$parentPlaceholder[$section] = '##parent-placeholder-'.sha1($section).'##';
179+
$salt = static::parentPlaceholderSalt();
180+
181+
static::$parentPlaceholder[$section] = '##parent-placeholder-'.sha1($salt.$section).'##';
172182
}
173183

174184
return static::$parentPlaceholder[$section];
175185
}
176186

177187
/**
178-
* Check if the section exists.
188+
* Get the parent placeholder salt.
189+
*
190+
* @return string
191+
*/
192+
protected static function parentPlaceholderSalt()
193+
{
194+
if (! static::$parentPlaceholderSalt) {
195+
return static::$parentPlaceholderSalt = Str::random(40);
196+
}
197+
198+
return static::$parentPlaceholderSalt;
199+
}
200+
201+
/**
202+
* Check if section exists.
179203
*
180204
* @param string $name
181205
* @return bool

tests/Database/DatabaseSqlServerSchemaGrammarTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public function testDropColumnDropsCreatesSqlToDropDefaultConstraints()
123123
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
124124

125125
$this->assertCount(1, $statements);
126-
$this->assertSame("DECLARE @sql NVARCHAR(MAX) = '';SELECT @sql += 'ALTER TABLE [dbo].[foo] DROP CONSTRAINT ' + OBJECT_NAME([default_object_id]) + ';' FROM SYS.COLUMNS WHERE [object_id] = OBJECT_ID('[dbo].[foo]') AND [name] in ('bar') AND [default_object_id] <> 0;EXEC(@sql);alter table \"foo\" drop column \"bar\"", $statements[0]);
126+
$this->assertSame("DECLARE @sql NVARCHAR(MAX) = '';SELECT @sql += 'ALTER TABLE [dbo].[foo] DROP CONSTRAINT ' + OBJECT_NAME([default_object_id]) + ';' FROM sys.columns WHERE [object_id] = OBJECT_ID('[dbo].[foo]') AND [name] in ('bar') AND [default_object_id] <> 0;EXEC(@sql);alter table \"foo\" drop column \"bar\"", $statements[0]);
127127
}
128128

129129
public function testDropPrimary()

tests/View/ViewBladeCompilerTest.php

+20-10
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ protected function tearDown(): void
1818
public function testIsExpiredReturnsTrueIfCompiledFileDoesntExist()
1919
{
2020
$compiler = new BladeCompiler($files = $this->getFiles(), __DIR__);
21-
$files->shouldReceive('exists')->once()->with(__DIR__.'/'.sha1('foo').'.php')->andReturn(false);
21+
$files->shouldReceive('exists')->once()->with(__DIR__.'/'.sha1('v2foo').'.php')->andReturn(false);
2222
$this->assertTrue($compiler->isExpired('foo'));
2323
}
2424

@@ -33,24 +33,24 @@ public function testCannotConstructWithBadCachePath()
3333
public function testIsExpiredReturnsTrueWhenModificationTimesWarrant()
3434
{
3535
$compiler = new BladeCompiler($files = $this->getFiles(), __DIR__);
36-
$files->shouldReceive('exists')->once()->with(__DIR__.'/'.sha1('foo').'.php')->andReturn(true);
36+
$files->shouldReceive('exists')->once()->with(__DIR__.'/'.sha1('v2foo').'.php')->andReturn(true);
3737
$files->shouldReceive('lastModified')->once()->with('foo')->andReturn(100);
38-
$files->shouldReceive('lastModified')->once()->with(__DIR__.'/'.sha1('foo').'.php')->andReturn(0);
38+
$files->shouldReceive('lastModified')->once()->with(__DIR__.'/'.sha1('v2foo').'.php')->andReturn(0);
3939
$this->assertTrue($compiler->isExpired('foo'));
4040
}
4141

4242
public function testCompilePathIsProperlyCreated()
4343
{
4444
$compiler = new BladeCompiler($this->getFiles(), __DIR__);
45-
$this->assertEquals(__DIR__.'/'.sha1('foo').'.php', $compiler->getCompiledPath('foo'));
45+
$this->assertEquals(__DIR__.'/'.sha1('v2foo').'.php', $compiler->getCompiledPath('foo'));
4646
}
4747

4848
public function testCompileCompilesFileAndReturnsContents()
4949
{
5050
$compiler = new BladeCompiler($files = $this->getFiles(), __DIR__);
5151
$files->shouldReceive('get')->once()->with('foo')->andReturn('Hello World');
5252
$files->shouldReceive('exists')->once()->with(__DIR__)->andReturn(true);
53-
$files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('foo').'.php', 'Hello World<?php /**PATH foo ENDPATH**/ ?>');
53+
$files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('v2foo').'.php', 'Hello World<?php /**PATH foo ENDPATH**/ ?>');
5454
$compiler->compile('foo');
5555
}
5656

@@ -60,7 +60,7 @@ public function testCompileCompilesFileAndReturnsContentsCreatingDirectory()
6060
$files->shouldReceive('get')->once()->with('foo')->andReturn('Hello World');
6161
$files->shouldReceive('exists')->once()->with(__DIR__)->andReturn(false);
6262
$files->shouldReceive('makeDirectory')->once()->with(__DIR__, 0777, true, true);
63-
$files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('foo').'.php', 'Hello World<?php /**PATH foo ENDPATH**/ ?>');
63+
$files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('v2foo').'.php', 'Hello World<?php /**PATH foo ENDPATH**/ ?>');
6464
$compiler->compile('foo');
6565
}
6666

@@ -69,7 +69,7 @@ public function testCompileCompilesAndGetThePath()
6969
$compiler = new BladeCompiler($files = $this->getFiles(), __DIR__);
7070
$files->shouldReceive('get')->once()->with('foo')->andReturn('Hello World');
7171
$files->shouldReceive('exists')->once()->with(__DIR__)->andReturn(true);
72-
$files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('foo').'.php', 'Hello World<?php /**PATH foo ENDPATH**/ ?>');
72+
$files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('v2foo').'.php', 'Hello World<?php /**PATH foo ENDPATH**/ ?>');
7373
$compiler->compile('foo');
7474
$this->assertSame('foo', $compiler->getPath());
7575
}
@@ -86,7 +86,7 @@ public function testCompileWithPathSetBefore()
8686
$compiler = new BladeCompiler($files = $this->getFiles(), __DIR__);
8787
$files->shouldReceive('get')->once()->with('foo')->andReturn('Hello World');
8888
$files->shouldReceive('exists')->once()->with(__DIR__)->andReturn(true);
89-
$files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('foo').'.php', 'Hello World<?php /**PATH foo ENDPATH**/ ?>');
89+
$files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('v2foo').'.php', 'Hello World<?php /**PATH foo ENDPATH**/ ?>');
9090
// set path before compilation
9191
$compiler->setPath('foo');
9292
// trigger compilation with $path
@@ -117,7 +117,7 @@ public function testIncludePathToTemplate($content, $compiled)
117117
$compiler = new BladeCompiler($files = $this->getFiles(), __DIR__);
118118
$files->shouldReceive('get')->once()->with('foo')->andReturn($content);
119119
$files->shouldReceive('exists')->once()->with(__DIR__)->andReturn(true);
120-
$files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('foo').'.php', $compiled);
120+
$files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('v2foo').'.php', $compiled);
121121

122122
$compiler->compile('foo');
123123
}
@@ -172,11 +172,21 @@ public function testDontIncludeEmptyPath()
172172
$compiler = new BladeCompiler($files = $this->getFiles(), __DIR__);
173173
$files->shouldReceive('get')->once()->with('')->andReturn('Hello World');
174174
$files->shouldReceive('exists')->once()->with(__DIR__)->andReturn(true);
175-
$files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('').'.php', 'Hello World');
175+
$files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('v2').'.php', 'Hello World');
176176
$compiler->setPath('');
177177
$compiler->compile();
178178
}
179179

180+
public function testDontIncludeNullPath()
181+
{
182+
$compiler = new BladeCompiler($files = $this->getFiles(), __DIR__);
183+
$files->shouldReceive('get')->once()->with(null)->andReturn('Hello World');
184+
$files->shouldReceive('exists')->once()->with(__DIR__)->andReturn(true);
185+
$files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('v2').'.php', 'Hello World');
186+
$compiler->setPath(null);
187+
$compiler->compile();
188+
}
189+
180190
public function testShouldStartFromStrictTypesDeclaration()
181191
{
182192
$compiler = new BladeCompiler($files = $this->getFiles(), __DIR__);

0 commit comments

Comments
 (0)