Page MenuHomePhabricator

mediawiki-directory-structure.patch

Authored By
bzimport
Nov 21 2014, 8:47 PM
Size
4 KB
Referenced Files
None
Subscribers
None

mediawiki-directory-structure.patch

diff -ur mediawiki/includes/GlobalFunctions.php mediawiki-path/includes/GlobalFunctions.php
--- mediawiki/includes/GlobalFunctions.php 2006-07-09 01:45:25.000000000 -0400
+++ mediawiki-path/includes/GlobalFunctions.php 2007-01-02 12:05:08.000000000 -0400
@@ -1796,6 +1796,20 @@
}
/**
+ * Return the path portion of a pathname.
+ *
+ * @param string $path
+ * @return string
+ */
+function wfBasePath( $path ) {
+ if( preg_match( '#^(.*/)#', $path, $matches ) ) {
+ return $matches[0];
+ } else {
+ return '';
+ }
+}
+
+/**
* Make a URL index, appropriate for the el_index field of externallinks.
*/
function wfMakeUrlIndex( $url ) {
diff -ur mediawiki/includes/ImagePage.php mediawiki-path/includes/ImagePage.php
--- mediawiki/includes/ImagePage.php 2006-07-09 01:45:25.000000000 -0400
+++ mediawiki-path/includes/ImagePage.php 2007-01-02 19:34:39.000000000 -0400
@@ -498,10 +498,10 @@
$wgOut->showUnexpectedValueError( 'oldimage', htmlspecialchars($oldimage) );
return;
}
- if ( strstr( $oldimage, "/" ) || strstr( $oldimage, "\\" ) ) {
- $wgOut->showUnexpectedValueError( 'oldimage', htmlspecialchars($oldimage) );
- return;
- }
+ //if ( strstr( $oldimage, "/" ) || strstr( $oldimage, "\\" ) ) {
+ // $wgOut->showUnexpectedValueError( 'oldimage', htmlspecialchars($oldimage) );
+ // return;
+ //} //Why is this here? Is this required? Can I delete it?
if ( !$this->doDeleteOldImage( $oldimage ) ) {
return;
}
@@ -562,10 +562,10 @@
$wgOut->showUnexpectedValueError( 'oldimage', htmlspecialchars($oldimage) );
return;
}
- if ( strstr( $oldimage, "/" ) || strstr( $oldimage, "\\" ) ) {
- $wgOut->showUnexpectedValueError( 'oldimage', htmlspecialchars($oldimage) );
- return;
- }
+ //if ( strstr( $oldimage, "/" ) || strstr( $oldimage, "\\" ) ) {
+ // $wgOut->showUnexpectedValueError( 'oldimage', htmlspecialchars($oldimage) );
+ // return;
+ //} // Why? Is this required? Can I delete this? - K.
if ( wfReadOnly() ) {
$wgOut->readOnlyPage();
@@ -600,6 +600,7 @@
return;
}
$oldver = wfTimestampNow() . "!{$name}";
+ wfMkdirParents(wfBasePath("${archive}/{$oldver}"));
$dbr =& wfGetDB( DB_SLAVE );
$size = $dbr->selectField( 'oldimage', 'oi_size', array( 'oi_archive_name' => $oldimage ) );
diff -ur mediawiki/includes/SpecialUpload.php mediawiki-path/includes/SpecialUpload.php
--- mediawiki/includes/SpecialUpload.php 2006-07-09 01:45:25.000000000 -0400
+++ mediawiki-path/includes/SpecialUpload.php 2007-01-02 15:45:36.000000000 -0400
@@ -172,8 +172,10 @@
# Chop off any directories in the given filename
if ( $this->mDestFile ) {
$basename = wfBaseName( $this->mDestFile );
+ $basepath = wfBasePath($this->mDestFile);
} else {
$basename = wfBaseName( $this->mOname );
+ $basepath = '';
}
/**
@@ -205,7 +207,7 @@
* Filter out illegal characters, and try to make a legible name
* out of it. We'll strip some silently that Title would die on.
*/
- $filtered = preg_replace ( "/[^".Title::legalChars()."]|:/", '-', $basename );
+ $filtered = preg_replace ( "/[^".Title::legalChars()."]|:/", '-', $basepath.$basename );
$nt = Title::newFromText( $filtered );
if( is_null( $nt ) ) {
$this->uploadError( wfMsgWikiHtml( 'illegalfilename', htmlspecialchars( $filtered ) ) );
@@ -366,17 +368,21 @@
global $wgOut;
$fname= "SpecialUpload::saveUploadedFile";
+
+ $basename = wfBaseName($saveName);
+ $basepath = wfBasePath($saveName);
$dest = wfImageDir( $saveName );
$archive = wfImageArchiveDir( $saveName );
- if ( !is_dir( $dest ) ) wfMkdirParents( $dest );
+ if ( !is_dir( $dest.'/'.$basepath ) ) wfMkdirParents( $dest.'/'.$basepath );
if ( !is_dir( $archive ) ) wfMkdirParents( $archive );
- $this->mSavedFile = "{$dest}/{$saveName}";
+ $this->mSavedFile = "{$dest}/${basepath}${basename}";
if( is_file( $this->mSavedFile ) ) {
$this->mUploadOldVersion = gmdate( 'YmdHis' ) . "!{$saveName}";
wfSuppressWarnings();
+ wfMkdirParents(wfBasePath("{$archive}/{$this->mUploadOldVersion}"));
$success = rename( $this->mSavedFile, "${archive}/{$this->mUploadOldVersion}" );
wfRestoreWarnings();
@@ -425,6 +431,7 @@
$archive = wfImageArchiveDir( $saveName, 'temp' );
if ( !is_dir ( $archive ) ) wfMkdirParents( $archive );
$stash = $archive . '/' . gmdate( "YmdHis" ) . '!' . $saveName;
+ wfMkdirParents(wfBasePath($stash));
$success = $this->mRemoveTempFile
? rename( $tempName, $stash )

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1828
Default Alt Text
mediawiki-directory-structure.patch (4 KB)

Event Timeline