mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Backport fix for Validation::uploadedFile to 2.x
Don't fail validation when the keys are not the expected order. Refs #8201
This commit is contained in:
parent
80f18448b5
commit
e4b939bba0
2 changed files with 18 additions and 1 deletions
|
@ -2505,4 +2505,20 @@ class ValidationTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertFalse(Validation::uploadedFile($file, $options), 'File is required.');
|
||||
}
|
||||
/**
|
||||
* Test uploaded file validation.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testUploadedFileWithDifferentFileParametersOrder() {
|
||||
$file = array(
|
||||
'name' => 'cake.power.gif',
|
||||
'error' => UPLOAD_ERR_OK,
|
||||
'tmp_name' => CORE_PATH . 'Cake' . DS . 'Test' . DS . 'test_app' . DS . 'webroot/img/cake.power.gif',
|
||||
'type' => 'text/plain',
|
||||
'size' => 201
|
||||
);
|
||||
$options = array();
|
||||
$this->assertTrue(Validation::uploadedFile($file, $options), 'Wrong order');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1016,7 +1016,8 @@ class Validation {
|
|||
if (!is_array($file)) {
|
||||
return false;
|
||||
}
|
||||
$keys = array('name', 'tmp_name', 'error', 'type', 'size');
|
||||
$keys = array('error', 'name', 'size', 'tmp_name', 'type');
|
||||
ksort($file);
|
||||
if (array_keys($file) != $keys) {
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue