r96399 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96398‎ | r96399 | r96400 >
Date:02:31, 7 September 2011
Author:nelson
Status:ok (Comments)
Tags:
Comment:
restore proper operation of getArchive{Path|Url}
Modified paths:
  • /trunk/phase3/includes/filerepo/File.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/filerepo/File.php
@@ -892,13 +892,18 @@
893893 /**
894894 * Get the relative path for an archived file
895895 *
896 - * @param $archiveName string the timestamped name of an archived image
897 - * @param $suffix bool|string if not false, the name of a thumbnail file
 896+ * @param $suffix bool|string if not false, the name of an archived thumbnail file
898897 *
899898 * @return string
900899 */
901 - function getArchiveRel( $archiveName ) {
902 - return 'archive/' . $this->getHashPath() . $archiveName;
 900+ function getArchiveRel( $suffix = false ) {
 901+ $path = 'archive/' . $this->getHashPath();
 902+ if ( $suffix === false ) {
 903+ $path = substr( $path, 0, -1 );
 904+ } else {
 905+ $path .= $suffix;
 906+ }
 907+ return $path;
903908 }
904909
905910 /**
@@ -921,12 +926,12 @@
922927 /**
923928 * Get the path of the archived file.
924929 *
925 - * @param $archiveName the timestamped name of an archived image
 930+ * @param $suffix bool|string if not false, the name of an archived file.
926931 *
927932 * @return string
928933 */
929 - function getArchivePath( $archiveName ) {
930 - return $this->repo->getZonePath( 'public' ) . '/' . $this->getArchiveRel( $archiveName );
 934+ function getArchivePath( $suffix = false ) {
 935+ return $this->repo->getZonePath( 'public' ) . '/' . $this->getArchiveRel( $suffix );
931936 }
932937
933938 /**
@@ -957,14 +962,20 @@
958963 }
959964
960965 /**
961 - * Get the URL of the archived file
 966+ * Get the URL of the archive directory, or a particular file if $suffix is specified
962967 *
963 - * @param $archiveName string
 968+ * @param $suffix bool|string if not false, the name of an archived file
964969 *
965970 * @return string
966971 */
967 - function getArchiveUrl( $archiveName ) {
968 - return $this->repo->getZoneUrl('public') . '/archive/' . $this->getHashPath() . rawurlencode( $archiveName );
 972+ function getArchiveUrl( $suffix = false ) {
 973+ $path = $this->repo->getZoneUrl('public') . '/archive/' . $this->getHashPath();
 974+ if ( $suffix === false ) {
 975+ $path = substr( $path, 0, -1 );
 976+ } else {
 977+ $path .= rawurlencode( $suffix );
 978+ }
 979+ return $path;
969980 }
970981
971982 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r96845REL1_18: MFT r96373, r96399reedy14:47, 12 September 2011

Comments

#Comment by Nikerabbit (talk | contribs)   08:22, 7 September 2011

Is it just me or is getArchivePath never used except in tests?

#Comment by Reedy (talk | contribs)   11:44, 7 September 2011

Seems to be used in the WikiSync extension

#Comment by Aaron Schulz (talk | contribs)   17:58, 8 September 2011

Was this reverting some revision?

#Comment by 😂 (talk | contribs)   18:18, 8 September 2011

This was a followup to r96373.

#Comment by RussNelson (talk | contribs)   18:50, 8 September 2011

Reverting only part of it. I didn't understand that possibly, someone somewhere is relying on the ability to call those functions without specifying an archived article name. It doesn't make any sense (to me) to do that, but .... don't change APIs silently, right?

Status & tagging log