Title: [219092] trunk/Websites/perf.webkit.org
Revision
219092
Author
[email protected]
Date
2017-07-03 14:14:52 -0700 (Mon, 03 Jul 2017)

Log Message

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.

Modified Paths

Diff

Modified: trunk/Websites/perf.webkit.org/ChangeLog (219091 => 219092)


--- trunk/Websites/perf.webkit.org/ChangeLog	2017-07-03 21:13:42 UTC (rev 219091)
+++ trunk/Websites/perf.webkit.org/ChangeLog	2017-07-03 21:14:52 UTC (rev 219092)
@@ -1,5 +1,24 @@
 2017-07-03  Ryosuke Niwa  <[email protected]>
 
+        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  <[email protected]>
+
         Prune unused uploaded files when the file quota is reached
         https://bugs.webkit.org/show_bug.cgi?id=174086
 

Modified: trunk/Websites/perf.webkit.org/public/include/uploaded-file-helpers.php (219091 => 219092)


--- trunk/Websites/perf.webkit.org/public/include/uploaded-file-helpers.php	2017-07-03 21:13:42 UTC (rev 219091)
+++ trunk/Websites/perf.webkit.org/public/include/uploaded-file-helpers.php	2017-07-03 21:14:52 UTC (rev 219092)
@@ -63,7 +63,7 @@
     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)
@@ -77,7 +77,7 @@
     }
 
     return array(
-        'author' => remote_user_name(),
+        'author' => $remote_user,
         'filename' => $input_file['name'],
         'extension' => $file_extension,
         'mime' => $input_file['type'], // Sanitize MIME types.
@@ -97,7 +97,7 @@
             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',

Modified: trunk/Websites/perf.webkit.org/server-tests/api-upload-root-tests.js (219091 => 219092)


--- trunk/Websites/perf.webkit.org/server-tests/api-upload-root-tests.js	2017-07-03 21:13:42 UTC (rev 219091)
+++ trunk/Websites/perf.webkit.org/server-tests/api-upload-root-tests.js	2017-07-03 21:14:52 UTC (rev 219092)
@@ -48,7 +48,8 @@
         ]
     };
 
-    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];
@@ -67,7 +68,9 @@
         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 () {
@@ -247,6 +250,7 @@
             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) => {
 
@@ -382,6 +386,7 @@
             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) => {
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to