Skip to content

Commit 252d81b

Browse files
Merge branch '8.x' into 9.x
2 parents d424ab7 + f3940f8 commit 252d81b

File tree

5 files changed

+59
-5
lines changed

5 files changed

+59
-5
lines changed

src/Illuminate/Database/Console/PruneCommand.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ public function handle(Dispatcher $events)
8787
protected function models()
8888
{
8989
if (! empty($models = $this->option('model'))) {
90-
return collect($models);
90+
return collect($models)->filter(function ($model) {
91+
return class_exists($model);
92+
})->values();
9193
}
9294

9395
$except = $this->option('except');
@@ -111,6 +113,8 @@ protected function models()
111113
});
112114
})->filter(function ($model) {
113115
return $this->isPrunable($model);
116+
})->filter(function ($model) {
117+
return class_exists($model);
114118
})->values();
115119
}
116120

src/Illuminate/Queue/Console/BatchesTableCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class BatchesTableCommand extends Command
4848
protected $composer;
4949

5050
/**
51-
* Create a new failed queue jobs table command instance.
51+
* Create a new batched queue jobs table command instance.
5252
*
5353
* @param \Illuminate\Filesystem\Filesystem $files
5454
* @param \Illuminate\Support\Composer $composer
@@ -86,15 +86,15 @@ public function handle()
8686
* @param string $table
8787
* @return string
8888
*/
89-
protected function createBaseMigration($table = 'failed_jobs')
89+
protected function createBaseMigration($table = 'job_batches')
9090
{
9191
return $this->laravel['migration.creator']->create(
9292
'create_'.$table.'_table', $this->laravel->databasePath().'/migrations'
9393
);
9494
}
9595

9696
/**
97-
* Replace the generated migration with the failed job table stub.
97+
* Replace the generated migration with the batches job table stub.
9898
*
9999
* @param string $path
100100
* @param string $table

src/Illuminate/Validation/Concerns/ValidatesAttributes.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,18 @@ public function validateDigits($attribute, $value, $parameters)
563563
{
564564
$this->requireParameterCount(1, $parameters, 'digits');
565565

566-
return ! preg_match('/[^0-9]/', $value)
566+
$length = strlen((string) $value);
567+
568+
if (((string) $value) === '.') {
569+
return false;
570+
}
571+
572+
// Make sure there is not more than one dot...
573+
if (($length - strlen(str_replace('.', '', (string) $value))) > 1) {
574+
return false;
575+
}
576+
577+
return ! preg_match('/[^0-9.]/', $value)
567578
&& strlen((string) $value) == $parameters[0];
568579
}
569580

tests/Database/PruneCommandTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@ public function testNonPrunableTest()
8989
$this->assertEquals(<<<'EOF'
9090
No prunable [Illuminate\Tests\Database\NonPrunableTestModel] records found.
9191

92+
EOF, str_replace("\r", '', $output->fetch()));
93+
}
94+
95+
public function testNonPrunableTestWithATrait()
96+
{
97+
$output = $this->artisan(['--model' => NonPrunableTrait::class]);
98+
99+
$this->assertEquals(<<<'EOF'
100+
No prunable models found.
101+
92102
EOF, str_replace("\r", '', $output->fetch()));
93103
}
94104

@@ -227,3 +237,8 @@ class NonPrunableTestModel extends Model
227237
{
228238
// ..
229239
}
240+
241+
trait NonPrunableTrait
242+
{
243+
use Prunable;
244+
}

tests/Validation/ValidationValidatorTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2325,6 +2325,30 @@ public function testValidateDigits()
23252325
$v = new Validator($trans, ['foo' => '2e7'], ['foo' => 'Digits:3']);
23262326
$this->assertTrue($v->fails());
23272327

2328+
$v = new Validator($trans, ['foo' => '1.2'], ['foo' => 'digits:3']);
2329+
$this->assertTrue($v->passes());
2330+
2331+
$v = new Validator($trans, ['foo' => '0.9876'], ['foo' => 'digits:5']);
2332+
$this->assertTrue($v->fails());
2333+
2334+
$v = new Validator($trans, ['foo' => '1..2'], ['foo' => 'digits:4']);
2335+
$this->assertTrue($v->fails());
2336+
2337+
$v = new Validator($trans, ['foo' => '123.456.789'], ['foo' => 'digits:10']);
2338+
$this->assertTrue($v->fails());
2339+
2340+
$v = new Validator($trans, ['foo' => '...'], ['foo' => 'digits:3']);
2341+
$this->assertTrue($v->fails());
2342+
2343+
$v = new Validator($trans, ['foo' => '.'], ['foo' => 'digits:1']);
2344+
$this->assertTrue($v->fails());
2345+
2346+
$v = new Validator($trans, ['foo' => '.2'], ['foo' => 'digits:2']);
2347+
$this->assertTrue($v->passes());
2348+
2349+
$v = new Validator($trans, ['foo' => '2.'], ['foo' => 'digits:2']);
2350+
$this->assertTrue($v->passes());
2351+
23282352
$trans = $this->getIlluminateArrayTranslator();
23292353
$v = new Validator($trans, ['foo' => '12345'], ['foo' => 'digits_between:1,6']);
23302354
$this->assertTrue($v->passes());

0 commit comments

Comments
 (0)