Skip to content

Commit de0071d

Browse files
committed
Merge remote-tracking branch 'upstream/8.x' into 8.x
2 parents 78d6ba0 + 8febec7 commit de0071d

File tree

177 files changed

+1364
-682
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

177 files changed

+1364
-682
lines changed

.github/workflows/databases.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: databases
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
mysql_57:
7+
runs-on: ubuntu-20.04
8+
9+
services:
10+
mysql:
11+
image: mysql:5.7
12+
env:
13+
MYSQL_ALLOW_EMPTY_PASSWORD: yes
14+
MYSQL_DATABASE: forge
15+
ports:
16+
- 3306:3306
17+
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
18+
19+
strategy:
20+
fail-fast: true
21+
22+
name: MySQL 5.7
23+
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v2
27+
28+
- name: Setup PHP
29+
uses: shivammathur/setup-php@v2
30+
with:
31+
php-version: 8.1
32+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_mysql
33+
tools: composer:v2
34+
coverage: none
35+
36+
- name: Install dependencies
37+
uses: nick-invision/retry@v1
38+
with:
39+
timeout_minutes: 5
40+
max_attempts: 5
41+
command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress
42+
43+
- name: Execute tests
44+
run: vendor/bin/phpunit tests/Integration/Database --verbose
45+
env:
46+
DB_CONNECTION: mysql
47+
DB_USERNAME: root
48+
49+
mysql_8:
50+
runs-on: ubuntu-20.04
51+
52+
services:
53+
mysql:
54+
image: mysql:8
55+
env:
56+
MYSQL_ALLOW_EMPTY_PASSWORD: yes
57+
MYSQL_DATABASE: forge
58+
ports:
59+
- 3306:3306
60+
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
61+
62+
strategy:
63+
fail-fast: true
64+
65+
name: MySQL 8.0
66+
67+
steps:
68+
- name: Checkout code
69+
uses: actions/checkout@v2
70+
71+
- name: Setup PHP
72+
uses: shivammathur/setup-php@v2
73+
with:
74+
php-version: 8.1
75+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_mysql
76+
tools: composer:v2
77+
coverage: none
78+
79+
- name: Install dependencies
80+
uses: nick-invision/retry@v1
81+
with:
82+
timeout_minutes: 5
83+
max_attempts: 5
84+
command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress
85+
86+
- name: Execute tests
87+
run: vendor/bin/phpunit tests/Integration/Database --verbose
88+
env:
89+
DB_CONNECTION: mysql
90+
DB_USERNAME: root

.styleci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
php:
22
preset: laravel
33
version: 8
4+
finder:
5+
not-name:
6+
- Enums.php
47
js:
58
finder:
69
not-name:

CHANGELOG-6.x.md

Lines changed: 7 additions & 1 deletion
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.35...6.x)
3+
## [Unreleased](https://github.com/laravel/framework/compare/v6.20.36...6.x)
4+
5+
6+
## [v6.20.36 (2021-10-19)](https://github.com/laravel/framework/compare/v6.20.35...v6.20.36)
7+
8+
### Fixed
9+
- Add new lost connection message to DetectsLostConnections for Vapor ([#39209](https://github.com/laravel/framework/pull/39209))
410

511

612
## [v6.20.35 (2021-10-05)](https://github.com/laravel/framework/compare/v6.20.34...v6.20.35)

bin/test.sh

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,50 @@
11
#!/usr/bin/env bash
22

3-
docker-compose down -t 0 &> /dev/null
3+
down=false
4+
php="8.0"
5+
6+
while true; do
7+
case "$1" in
8+
--down ) down=true; shift ;;
9+
--php ) php=$2; shift 2;;
10+
-- ) shift; break ;;
11+
* ) break ;;
12+
esac
13+
done
14+
15+
if $down; then
16+
docker-compose down -t 0
17+
18+
exit 0
19+
fi
20+
21+
echo "Ensuring docker is running"
22+
23+
if ! docker info > /dev/null 2>&1; then
24+
echo "Please start docker first."
25+
exit 1
26+
fi
27+
28+
echo "Ensuring services are running"
29+
430
docker-compose up -d
531

6-
echo "Waiting for services to boot ..."
32+
if docker run -it --rm "registry.gitlab.com/grahamcampbell/php:$php-base" -r "\$tries = 0; while (true) { try { \$tries++; if (\$tries > 30) { throw new RuntimeException('MySQL never became available'); } sleep(1); new PDO('mysql:host=docker.for.mac.localhost;dbname=forge', 'root', '', [PDO::ATTR_TIMEOUT => 3]); break; } catch (PDOException \$e) {} }"; then
33+
echo "Running tests"
734

8-
if docker run -it --rm registry.gitlab.com/grahamcampbell/php:7.4-base -r "\$tries = 0; while (true) { try { \$tries++; if (\$tries > 30) { throw new RuntimeException('MySQL never became available'); } sleep(1); new PDO('mysql:host=docker.for.mac.localhost;dbname=forge', 'root', '', [PDO::ATTR_TIMEOUT => 3]); break; } catch (PDOException \$e) {} }"; then
9-
if docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpunit \
35+
if docker run -it -w /data -v ${PWD}:/data:delegated \
36+
--user "www-data" --entrypoint vendor/bin/phpunit \
1037
--env CI=1 --env DB_HOST=docker.for.mac.localhost --env DB_USERNAME=root \
38+
--env DB_HOST=docker.for.mac.localhost --env DB_PORT=3306 \
39+
--env DYNAMODB_ENDPOINT=docker.for.mac.localhost:8000 --env DYNAMODB_CACHE_TABLE=cache --env AWS_ACCESS_KEY_ID=dummy --env AWS_SECRET_ACCESS_KEY=dummy \
1140
--env REDIS_HOST=docker.for.mac.localhost --env REDIS_PORT=6379 \
1241
--env MEMCACHED_HOST=docker.for.mac.localhost --env MEMCACHED_PORT=11211 \
13-
--rm registry.gitlab.com/grahamcampbell/php:7.4-base "$@"; then
14-
docker-compose down -t 0
42+
--rm "registry.gitlab.com/grahamcampbell/php:$php-base" "$@"; then
43+
exit 0
1544
else
16-
docker-compose down -t 0
1745
exit 1
1846
fi
1947
else
2048
docker-compose logs
21-
docker-compose down -t 0 &> /dev/null
2249
exit 1
2350
fi

docker-compose.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
version: '3'
22
services:
3+
dynamodb:
4+
image: amazon/dynamodb-local
5+
ports:
6+
- "8000:8000"
7+
command: ["-jar", "DynamoDBLocal.jar", "-sharedDb", "-inMemory"]
38
memcached:
49
image: memcached:1.6-alpine
510
ports:
611
- "11211:11211"
712
restart: always
813
mysql:
9-
image: mysql:5.7
14+
image: mysql/mysql-server:5.7
1015
environment:
1116
MYSQL_ALLOW_EMPTY_PASSWORD: 1
1217
MYSQL_ROOT_PASSWORD: ""
1318
MYSQL_DATABASE: "forge"
19+
MYSQL_ROOT_HOST: "%"
1420
ports:
1521
- "3306:3306"
1622
restart: always

src/Illuminate/Auth/DatabaseUserProvider.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Illuminate\Auth;
44

5+
use Closure;
56
use Illuminate\Contracts\Auth\Authenticatable as UserContract;
67
use Illuminate\Contracts\Auth\UserProvider;
78
use Illuminate\Contracts\Hashing\Hasher as HasherContract;
@@ -117,6 +118,8 @@ public function retrieveByCredentials(array $credentials)
117118

118119
if (is_array($value) || $value instanceof Arrayable) {
119120
$query->whereIn($key, $value);
121+
} elseif ($value instanceof Closure) {
122+
$value($query);
120123
} else {
121124
$query->where($key, $value);
122125
}

src/Illuminate/Auth/EloquentUserProvider.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Illuminate\Auth;
44

5+
use Closure;
56
use Illuminate\Contracts\Auth\Authenticatable as UserContract;
67
use Illuminate\Contracts\Auth\UserProvider;
78
use Illuminate\Contracts\Hashing\Hasher as HasherContract;
@@ -123,6 +124,8 @@ public function retrieveByCredentials(array $credentials)
123124

124125
if (is_array($value) || $value instanceof Arrayable) {
125126
$query->whereIn($key, $value);
127+
} elseif ($value instanceof Closure) {
128+
$value($query);
126129
} else {
127130
$query->where($key, $value);
128131
}

src/Illuminate/Cache/RateLimiter.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ public function attempt($key, $maxAttempts, Closure $callback, $decaySeconds = 6
8989
*/
9090
public function tooManyAttempts($key, $maxAttempts)
9191
{
92+
$key = $this->cleanRateLimiterKey($key);
93+
9294
if ($this->attempts($key) >= $maxAttempts) {
9395
if ($this->cache->has($key.':timer')) {
9496
return true;
@@ -109,6 +111,8 @@ public function tooManyAttempts($key, $maxAttempts)
109111
*/
110112
public function hit($key, $decaySeconds = 60)
111113
{
114+
$key = $this->cleanRateLimiterKey($key);
115+
112116
$this->cache->add(
113117
$key.':timer', $this->availableAt($decaySeconds), $decaySeconds
114118
);
@@ -132,6 +136,8 @@ public function hit($key, $decaySeconds = 60)
132136
*/
133137
public function attempts($key)
134138
{
139+
$key = $this->cleanRateLimiterKey($key);
140+
135141
return $this->cache->get($key, 0);
136142
}
137143

@@ -143,6 +149,8 @@ public function attempts($key)
143149
*/
144150
public function resetAttempts($key)
145151
{
152+
$key = $this->cleanRateLimiterKey($key);
153+
146154
return $this->cache->forget($key);
147155
}
148156

@@ -155,6 +163,8 @@ public function resetAttempts($key)
155163
*/
156164
public function remaining($key, $maxAttempts)
157165
{
166+
$key = $this->cleanRateLimiterKey($key);
167+
158168
$attempts = $this->attempts($key);
159169

160170
return $maxAttempts - $attempts;
@@ -180,6 +190,8 @@ public function retriesLeft($key, $maxAttempts)
180190
*/
181191
public function clear($key)
182192
{
193+
$key = $this->cleanRateLimiterKey($key);
194+
183195
$this->resetAttempts($key);
184196

185197
$this->cache->forget($key.':timer');
@@ -193,6 +205,19 @@ public function clear($key)
193205
*/
194206
public function availableIn($key)
195207
{
208+
$key = $this->cleanRateLimiterKey($key);
209+
196210
return max(0, $this->cache->get($key.':timer') - $this->currentTime());
197211
}
212+
213+
/**
214+
* Clean the rate limiter key from unicode characters.
215+
*
216+
* @param string $key
217+
* @return string
218+
*/
219+
public function cleanRateLimiterKey($key)
220+
{
221+
return preg_replace('/&([a-z])[a-z]+;/i', '$1', htmlentities($key));
222+
}
198223
}

src/Illuminate/Database/DBAL/TimestampType.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
use Doctrine\DBAL\DBALException;
66
use Doctrine\DBAL\Platforms\AbstractPlatform;
7+
use Doctrine\DBAL\Types\PhpDateTimeMappingType;
78
use Doctrine\DBAL\Types\Type;
89

9-
class TimestampType extends Type
10+
class TimestampType extends Type implements PhpDateTimeMappingType
1011
{
1112
/**
1213
* {@inheritdoc}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace Illuminate\Database\Eloquent\Casts;
4+
5+
use Illuminate\Contracts\Database\Eloquent\Castable;
6+
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
7+
use Illuminate\Support\Str;
8+
9+
class AsStringable implements Castable
10+
{
11+
/**
12+
* Get the caster class to use when casting from / to this cast target.
13+
*
14+
* @param array $arguments
15+
* @return object|string
16+
*/
17+
public static function castUsing(array $arguments)
18+
{
19+
return new class implements CastsAttributes
20+
{
21+
public function get($model, $key, $value, $attributes)
22+
{
23+
return isset($value) ? Str::of($value) : null;
24+
}
25+
26+
public function set($model, $key, $value, $attributes)
27+
{
28+
return isset($value) ? (string) $value : null;
29+
}
30+
};
31+
}
32+
}

0 commit comments

Comments
 (0)