aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Starling <tstarling@users.mediawiki.org>2006-11-18 05:23:41 +0000
committerTim Starling <tstarling@users.mediawiki.org>2006-11-18 05:23:41 +0000
commit80e6142d36b2a2af5d6ea768e94ff95c50bff34e (patch)
tree55f9397b679969cfeddfe0257fa17ea3a47871f5
parent900cf95baa9362c6ae72bc38a5c458a62a4cdb9f (diff)
downloadmediawikicore-80e6142d36b2a2af5d6ea768e94ff95c50bff34e.tar.gz
mediawikicore-80e6142d36b2a2af5d6ea768e94ff95c50bff34e.zip
Don't dump the MediaWiki namespace. Protection against overlong filenames. Always use dest/$imageRel as the upload directory. Display a warning if makeSnapshot is disabled. Display a warning if symlink/copy fails.
Notes
Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/17778
-rw-r--r--maintenance/dumpHTML.inc36
1 files changed, 27 insertions, 9 deletions
diff --git a/maintenance/dumpHTML.inc b/maintenance/dumpHTML.inc
index 52c8bcbfc9ac..86f675c250f4 100644
--- a/maintenance/dumpHTML.inc
+++ b/maintenance/dumpHTML.inc
@@ -185,7 +185,8 @@ class DumpHTML {
$title = Title::newFromID( $id );
if ( $title ) {
$ns = $title->getNamespace() ;
- if ( $ns != NS_CATEGORY && $title->getPrefixedDBkey() != $mainPage ) {
+ if ( $ns != NS_CATEGORY && $ns != NS_MEDIAWIKI &&
+ $title->getPrefixedDBkey() != $mainPage ) {
$this->doArticle( $title );
}
}
@@ -485,11 +486,26 @@ class DumpHTML {
fclose( $file );
}
}
+
+ wfIncrStats( 'dumphtml_article' );
}
/** Write the given text to the file identified by the given title object */
function writeArticle( &$title, $text ) {
$filename = $this->getHashedFilename( $title );
+
+ # Temporary hack for current dump, this should be moved to
+ # getFriendlyName() at the earliest opportunity.
+ #
+ # Limit filename length to 255 characters, so it works on ext3.
+ # Titles are in fact limited to 255 characters, but dumpHTML
+ # adds a suffix which may put them over the limit.
+ $length = strlen( $filename );
+ if ( $length > 255 ) {
+ print "Warning: Filename too long ($length bytes). Skipping.\n";
+ return;
+ }
+
$fullName = "{$this->dest}/$filename";
$fullDir = dirname( $fullName );
@@ -591,13 +607,11 @@ class DumpHTML {
$wgUser->setOption( 'skin', $this->skin );
$wgUser->setOption( 'editsection', 0 );
- if ( $this->makeSnapshot ) {
- $this->destUploadDirectory = "{$this->dest}/{$this->imageRel}";
- if ( realpath( $this->destUploadDirectory == $wgUploadDirectory ) ) {
- $this->makeSnapshot = false;
- }
+ $this->destUploadDirectory = "{$this->dest}/{$this->imageRel}";
+ if ( realpath( $this->destUploadDirectory ) == realpath( $wgUploadDirectory ) ) {
+ print "Disabling image snapshot because the destination is the same as the source\n";
+ $this->makeSnapshot = false;
}
-
$this->sharedStaticDirectory = "{$this->destUploadDirectory}/shared";
$this->setupDone = true;
@@ -695,9 +709,13 @@ ENDTEXT;
if ( !file_exists( $destLoc ) ) {
wfMkdirParents( dirname( $destLoc ), 0755 );
if ( function_exists( 'symlink' ) && !$this->forceCopy ) {
- symlink( $sourceLoc, $destLoc );
+ if ( !symlink( $sourceLoc, $destLoc ) ) {
+ print "Warning: unable to create symlink at $destLoc\n";
+ }
} else {
- copy( $sourceLoc, $destLoc );
+ if ( !copy( $sourceLoc, $destLoc ) ) {
+ print "Warning: unable to copy $sourceLoc to $destLoc\n";
+ }
}
}
}