Skip to content

Commit a7ebbfa

Browse files
committed
Merge branch '5.4' of github.com:laravel/framework into 5.4
2 parents 097f02f + ca3955f commit a7ebbfa

File tree

5 files changed

+20
-3
lines changed

5 files changed

+20
-3
lines changed

src/Illuminate/Queue/Worker.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ protected function getNextJob($connection, $queue)
247247

248248
$this->stopWorkerIfLostConnection($e);
249249
} catch (Throwable $e) {
250-
$this->exceptions->report(new FatalThrowableError($e));
250+
$this->exceptions->report($e = new FatalThrowableError($e));
251251

252252
$this->stopWorkerIfLostConnection($e);
253253
}
@@ -270,7 +270,7 @@ protected function runJob($job, $connectionName, WorkerOptions $options)
270270

271271
$this->stopWorkerIfLostConnection($e);
272272
} catch (Throwable $e) {
273-
$this->exceptions->report(new FatalThrowableError($e));
273+
$this->exceptions->report($e = new FatalThrowableError($e));
274274

275275
$this->stopWorkerIfLostConnection($e);
276276
}

src/Illuminate/Validation/Concerns/ValidatesAttributes.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,9 @@ protected function failsRatioCheck($parameters, $width, $height)
478478
[1, 1], array_filter(sscanf($parameters['ratio'], '%f/%d'))
479479
);
480480

481-
return abs($numerator / $denominator - $width / $height) > 0.000001;
481+
$precision = 1 / max($width, $height);
482+
483+
return abs($numerator / $denominator - $width / $height) > $precision;
482484
}
483485

484486
/**

tests/Validation/ValidationDimensionsRuleTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,9 @@ public function testItCorrectlyFormatsAStringVersionOfTheRule()
2121
$rule = Rule::dimensions()->maxWidth(1000)->maxHeight(500)->ratio(3 / 2);
2222

2323
$this->assertEquals('dimensions:max_width=1000,max_height=500,ratio=1.5', (string) $rule);
24+
25+
$rule = new Dimensions(['ratio' => '2/3']);
26+
27+
$this->assertEquals('dimensions:ratio=2/3', (string) $rule);
2428
}
2529
}

tests/Validation/ValidationValidatorTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1972,6 +1972,9 @@ public function testValidateImage()
19721972
$this->assertTrue($v->passes());
19731973
}
19741974

1975+
/**
1976+
* @group dimension
1977+
*/
19751978
public function testValidateImageDimensions()
19761979
{
19771980
// Knowing that demo image.png has width = 3 and height = 2
@@ -2037,6 +2040,14 @@ public function testValidateImageDimensions()
20372040

20382041
$v = new Validator($trans, ['x' => $emptyUploadedFile], ['x' => 'dimensions:min_width=1']);
20392042
$this->assertTrue($v->fails());
2043+
2044+
// Knowing that demo image3.png has width = 7 and height = 10
2045+
$uploadedFile = new \Symfony\Component\HttpFoundation\File\UploadedFile(__DIR__.'/fixtures/image3.png', '', null, null, null, true);
2046+
$trans = $this->getIlluminateArrayTranslator();
2047+
2048+
// Ensure validation doesn't erroneously fail when ratio has no fractional part
2049+
$v = new Validator($trans, ['x' => $uploadedFile], ['x' => 'dimensions:ratio=2/3']);
2050+
$this->assertTrue($v->passes());
20402051
}
20412052

20422053
/**
82 Bytes
Loading

0 commit comments

Comments
 (0)