r76750 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76749‎ | r76750 | r76751 >
Date:01:15, 16 November 2010
Author:neilk
Status:ok
Tags:
Comment:
removed URL hackery, now using SpecialPage::getTitleFor(). Followup to r75906
Modified paths:
  • /trunk/phase3/includes/upload/UploadStash.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/upload/UploadStash.php
@@ -24,9 +24,6 @@
2525 // array of initialized objects obtained from session (lazily initialized upon getFile())
2626 private $files = array();
2727
28 - // the base URL for files in the stash
29 - private $baseUrl;
30 -
3128 // TODO: Once UploadBase starts using this, switch to use these constants rather than UploadBase::SESSION*
3229 // const SESSION_VERSION = 2;
3330 // const SESSION_KEYNAME = 'wsUploadData';
@@ -53,19 +50,9 @@
5451 $_SESSION[UploadBase::SESSION_KEYNAME] = array();
5552 }
5653
57 - $this->baseUrl = SpecialPage::getTitleFor( 'UploadStash' )->getLocalURL();
5854 }
5955
6056 /**
61 - * Get the base of URLs by which one can access the files
62 - *
63 - * @return String: url
64 - */
65 - public function getBaseUrl() {
66 - return $this->baseUrl;
67 - }
68 -
69 - /**
7057 * Get a file and its metadata from the stash.
7158 * May throw exception if session data cannot be parsed due to schema change, or key not found.
7259 *
@@ -298,6 +285,16 @@
299286 return $thumbName;
300287 }
301288
 289+ /**
 290+ * Helper function -- given a 'subpage', return the local URL e.g. /wiki/Special:UploadStash/subpage
 291+ * @param {String} $subPage
 292+ * @return {String} local URL for this subpage in the Special:UploadStash space.
 293+ */
 294+ private function getSpecialUrl( $subPage ) {
 295+ return SpecialPage::getTitleFor( 'UploadStash', $subPage )->getLocalURL();
 296+ }
 297+
 298+
302299 /**
303300 * Get a URL to access the thumbnail
304301 * This is required because the model of how files work requires that
@@ -308,11 +305,7 @@
309306 * @return String: URL to access thumbnail, or URL with partial path
310307 */
311308 public function getThumbUrl( $thumbName = false ) {
312 - $path = $this->sessionStash->getBaseUrl();
313 - if ( $thumbName !== false ) {
314 - $path .= '/' . rawurlencode( $thumbName );
315 - }
316 - return $path;
 309+ return self::getSpecialUrl( $thumbName );
317310 }
318311
319312 /**
@@ -336,7 +329,7 @@
337330 */
338331 public function getUrl() {
339332 if ( !isset( $this->url ) ) {
340 - $this->url = $this->sessionStash->getBaseUrl() . '/' . $this->getUrlName();
 333+ $this->url = self::getSpecialUrl( $this->getUrlName() );
341334 }
342335 return $this->url;
343336 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r76797uploadwizard-deployment: Merge recent revs from trunk: r75995, r76354, r76386...catrope14:47, 16 November 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r75906core changes for UploadWizard (merged from r73549 to HEAD in branches/uploadw...neilk04:32, 3 November 2010

Status & tagging log