Use TempFSFile in UploadFromUrl
authorBryan Davis <bd808@wikimedia.org>
Thu, 12 Dec 2013 23:10:14 +0000 (16:10 -0700)
committerBryan Davis <bd808@wikimedia.org>
Thu, 12 Dec 2013 23:10:14 +0000 (16:10 -0700)
Make it a little harder for the developer to leak files in the temp
directory by managing the temporary file with a TempFSFile instance.

Change-Id: I8bafc3a6e6212781d9e2e4f8f370ce7c446f1fd5

includes/upload/UploadFromUrl.php

index 0201d5f..6d956e2 100644 (file)
@@ -204,13 +204,16 @@ class UploadFromUrl extends UploadBase {
                }
                return Status::newGood();
        }
+
        /**
         * Create a new temporary file in the URL subdirectory of wfTempDir().
         *
         * @return string Path to the file
         */
        protected function makeTemporaryFile() {
-               return tempnam( wfTempDir(), 'URL' );
+               $tmpFile = new TempFSFile( 'URL' );
+               $tmpFile->bind( $this );
+               return $tmpFile->getPath();
        }
 
        /**