https://bugs.webkit.org/show_bug.cgi?id=174087
Reviewed by Andreas Kling.
When a root file is uploaded from the bot, we manually specify the remote user to upload_file_in_transaction.
However, this was getting ignored by create_uploaded_file_from_form_data since it was always calling
remote_user_name to get the user name off of $_SERVER.
Fixed the bug by passing in the user name from upload_file_in_transaction to create_uploaded_file_from_form_data.
* public/include/uploaded-file-helpers.php:
(create_uploaded_file_from_form_data): Take the remote user as an argument instead of calling remote_user_name.
(upload_file_in_transaction):
* server-tests/api-upload-root-tests.js: Updated an existing test cases to make sure root files' author is set.
(createTestGroupWihPatch): Manually override the author of a test group for testing.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219092
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
2017-07-03 Ryosuke Niwa <rniwa@webkit.org>
+ Roots uploaded by bots don't get author specified properly
+ https://bugs.webkit.org/show_bug.cgi?id=174087
+
+ Reviewed by Andreas Kling.
+
+ When a root file is uploaded from the bot, we manually specify the remote user to upload_file_in_transaction.
+ However, this was getting ignored by create_uploaded_file_from_form_data since it was always calling
+ remote_user_name to get the user name off of $_SERVER.
+
+ Fixed the bug by passing in the user name from upload_file_in_transaction to create_uploaded_file_from_form_data.
+
+ * public/include/uploaded-file-helpers.php:
+ (create_uploaded_file_from_form_data): Take the remote user as an argument instead of calling remote_user_name.
+ (upload_file_in_transaction):
+ * server-tests/api-upload-root-tests.js: Updated an existing test cases to make sure root files' author is set.
+ (createTestGroupWihPatch): Manually override the author of a test group for testing.
+
+2017-07-03 Ryosuke Niwa <rniwa@webkit.org>
+
Prune unused uploaded files when the file quota is reached
https://bugs.webkit.org/show_bug.cgi?id=174086
return intval($count_result[0]["sum"]);
}
-function create_uploaded_file_from_form_data($input_file)
+function create_uploaded_file_from_form_data($input_file, $remote_user)
{
$file_sha256 = hash_file('sha256', $input_file['tmp_name']);
if (!$file_sha256)
}
return array(
- 'author' => remote_user_name(),
+ 'author' => $remote_user,
'filename' => $input_file['name'],
'extension' => $file_extension,
'mime' => $input_file['type'], // Sanitize MIME types.
exit_with_error('FileSizeQuotaExceeded');
}
- $uploaded_file = create_uploaded_file_from_form_data($input_file);
+ $uploaded_file = create_uploaded_file_from_form_data($input_file, $remote_user);
$db->begin_transaction();
$file_row = $db->select_or_insert_row('uploaded_files', 'file',
]
};
- return MockData.addMockData(TestServer.database()).then(() => {
+ const db = TestServer.database();
+ return MockData.addMockData(db).then(() => {
return Promise.all([TemporaryFile.makeTemporaryFile('patch.dat', 'patch file'), Manifest.fetch()]);
}).then((result) => {
const patchFile = result[0];
return TestGroup.createWithTask('custom task', Platform.findById(MockData.somePlatformId()), someTest, 'some group', 2, [set1, set2]);
}).then((task) => {
return TestGroup.findAllByTask(task.id())[0];
- })
+ }).then((group) => {
+ return db.query('UPDATE analysis_test_groups SET testgroup_author = $1', ['someUser']).then(() => group);
+ });
}
describe('/api/upload-root/', function () {
const uploadedRootRawData = response['uploadedFile'];
uploadedRoot = UploadedFile.ensureSingleton(uploadedRootRawData.id, uploadedRootRawData);
assert.equal(uploadedRoot.filename(), 'some.dat');
+ assert.equal(uploadedRoot.author(), 'someUser');
return TestGroup.fetchForTask(buildRequest.testGroup().task().id(), true);
}).then((testGroups) => {
const uploadedRootRawData = response['uploadedFile'];
uploadedRoot = UploadedFile.ensureSingleton(uploadedRootRawData.id, uploadedRootRawData);
assert.equal(uploadedRoot.filename(), 'some.dat');
+ assert.equal(uploadedRoot.author(), 'someUser');
return TestGroup.fetchForTask(buildRequest.testGroup().task().id(), true);
}).then((testGroups) => {