google/appengine/runtime/UnlinkUploads.php
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
\google\appengine\runtime\UnlinkUploads
The shutdown hook is registered in Setup.php if $_FILES is not empty. Users are expected to use move_uploaded_file() to place wanted files in proper location.
If changes are made to the $_FILES array the shutdown hook will have an unmodified copy which both prevents tampering and allows empty files to be removed along with others after removeEmptyFiles() cleans the array.
GCS creates empty files when a POST request is sent with empty file fields. Typically PHP would ignore the file fields signified using UPLOAD_ERR_NO_FILE in the $_FILES array entry. Instead rfc1867.c is modified to pass the entries along with UNLINK as the file name to ensure the tmp_name is filled with gs:// address and can be unlinked along with any unprocessed uploads.