Index: trunk/phase3/includes/upload/UploadFromUrl.php |
— | — | @@ -33,19 +33,19 @@ |
34 | 34 | |
35 | 35 | /** |
36 | 36 | * Entry point for API upload |
37 | | - * |
| 37 | + * |
38 | 38 | * @param $name string |
39 | 39 | * @param $url string |
40 | | - * @param $async mixed Whether the download should be performed |
| 40 | + * @param $async mixed Whether the download should be performed |
41 | 41 | * asynchronous. False for synchronous, async or async-leavemessage for |
42 | 42 | * asynchronous download. |
43 | 43 | */ |
44 | 44 | public function initialize( $name, $url, $async = false ) { |
45 | 45 | global $wgAllowAsyncCopyUploads; |
46 | | - |
| 46 | + |
47 | 47 | $this->mUrl = $url; |
48 | 48 | $this->mAsync = $wgAllowAsyncCopyUploads ? $async : false; |
49 | | - |
| 49 | + |
50 | 50 | $tempPath = $this->mAsync ? null : $this->makeTemporaryFile(); |
51 | 51 | # File size and removeTempFile will be filled in later |
52 | 52 | $this->initializePathInfo( $name, $tempPath, 0, false ); |
— | — | @@ -77,13 +77,13 @@ |
78 | 78 | && Http::isValidURI( $url ) |
79 | 79 | && $wgUser->isAllowed( 'upload_by_url' ); |
80 | 80 | } |
81 | | - |
82 | 81 | |
| 82 | + |
83 | 83 | public function fetchFile() { |
84 | 84 | if ( !Http::isValidURI( $this->mUrl ) ) { |
85 | 85 | return Status::newFatal( 'http-invalid-url' ); |
86 | 86 | } |
87 | | - |
| 87 | + |
88 | 88 | if ( !$this->mAsync ) { |
89 | 89 | return $this->reallyFetchFile(); |
90 | 90 | } |
— | — | @@ -91,7 +91,7 @@ |
92 | 92 | } |
93 | 93 | /** |
94 | 94 | * Create a new temporary file in the URL subdirectory of wfTempDir(). |
95 | | - * |
| 95 | + * |
96 | 96 | * @return string Path to the file |
97 | 97 | */ |
98 | 98 | protected function makeTemporaryFile() { |
— | — | @@ -99,8 +99,8 @@ |
100 | 100 | } |
101 | 101 | /** |
102 | 102 | * Save the result of a HTTP request to the temporary file |
103 | | - * |
104 | | - * @param $req MWHttpRequest |
| 103 | + * |
| 104 | + * @param $req MWHttpRequest |
105 | 105 | * @return Status |
106 | 106 | */ |
107 | 107 | private function saveTempFile( $req ) { |
— | — | @@ -137,7 +137,7 @@ |
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
141 | | - * Wrapper around the parent function in order to defer verifying the |
| 141 | + * Wrapper around the parent function in order to defer verifying the |
142 | 142 | * upload until the file really has been fetched. |
143 | 143 | */ |
144 | 144 | public function verifyUpload() { |
— | — | @@ -158,7 +158,7 @@ |
159 | 159 | } |
160 | 160 | return parent::checkWarnings(); |
161 | 161 | } |
162 | | - |
| 162 | + |
163 | 163 | /** |
164 | 164 | * Wrapper around the parent function in order to defer checking protection |
165 | 165 | * until we are sure that the file can actually be uploaded |
— | — | @@ -169,7 +169,7 @@ |
170 | 170 | } |
171 | 171 | return parent::verifyPermissions( $user ); |
172 | 172 | } |
173 | | - |
| 173 | + |
174 | 174 | /** |
175 | 175 | * Wrapper around the parent function in order to defer uploading to the |
176 | 176 | * job queue for asynchronous uploads |
— | — | @@ -177,18 +177,18 @@ |
178 | 178 | public function performUpload( $comment, $pageText, $watch, $user ) { |
179 | 179 | if ( $this->mAsync ) { |
180 | 180 | $sessionKey = $this->insertJob( $comment, $pageText, $watch, $user ); |
181 | | - |
| 181 | + |
182 | 182 | $status = new Status; |
183 | 183 | $status->error( 'async', $sessionKey ); |
184 | 184 | return $status; |
185 | 185 | } |
186 | | - |
| 186 | + |
187 | 187 | return parent::performUpload( $comment, $pageText, $watch, $user ); |
188 | 188 | } |
189 | 189 | |
190 | | - |
| 190 | + |
191 | 191 | protected function insertJob( $comment, $pageText, $watch, $user ) { |
192 | | - $sessionKey = $this->getSessionKey(); |
| 192 | + $sessionKey = $this->stashSession(); |
193 | 193 | $job = new UploadFromUrlJob( $this->getTitle(), array( |
194 | 194 | 'url' => $this->mUrl, |
195 | 195 | 'comment' => $comment, |
— | — | @@ -204,6 +204,6 @@ |
205 | 205 | $job->insert(); |
206 | 206 | return $sessionKey; |
207 | 207 | } |
208 | | - |
209 | 208 | |
| 209 | + |
210 | 210 | } |