https://www.mediawiki.org/wiki/Special:Code/MediaWiki/114434
Revision: 114434 Author: aaron Date: 2012-03-23 00:25:57 +0000 (Fri, 23 Mar 2012) Log Message: ----------- Committed live changes to file cleanup script Modified Paths: -------------- branches/wmf/1.19wmf1/maintenance/fixBug35048Files.php Modified: branches/wmf/1.19wmf1/maintenance/fixBug35048Files.php =================================================================== --- branches/wmf/1.19wmf1/maintenance/fixBug35048Files.php 2012-03-23 00:14:18 UTC (rev 114433) +++ branches/wmf/1.19wmf1/maintenance/fixBug35048Files.php 2012-03-23 00:25:57 UTC (rev 114434) @@ -93,6 +93,7 @@ $this->output( "Switching '$currentFilePath' with '$archivedFilePath'.\n" ); $tmpFilePath = "$wgUploadDirectory/lost+found/" . md5( $currentFilePath ); if ( !is_writable( $currentFilePath ) || !is_writable( $archivedFilePath ) ) { + $this->output( "'$currentFilePath' or '$archivedFilePath' not writable\n" ); continue; } $ok = rename( $currentFilePath, $tmpFilePath ) // temp @@ -108,17 +109,21 @@ } // Update DB to point to former current version next run (in $history loop)... } else { + if ( !is_writable( $currentFilePath ) || !is_writable( $archivedFilePath ) ) { + $this->output( "'$currentFilePath' or '$archivedFilePath' not writable\n" ); + continue; + } // Evict the current version to lost+found so it can be properly // re-uploaded later, with the username, comment, and log entry. $this->output( "Evicting '$currentFilePath' to '$wgUploadDirectory/lost+found/$name'.\n" ); - #rename( $currentFilePath, "$wgUploadDirectory/lost+found/" . $file->getName() ); + rename( $currentFilePath, "$wgUploadDirectory/lost+found/" . $file->getName() ); // Restore the orphaned archived version to current version file // name so that it matches up with the current version metadata. $this->output( "Moving '$archivedFilePath' back to '$currentFilePath'.\n" ); - #rename( $archivedFilePath, $currentFilePath ); + rename( $archivedFilePath, $currentFilePath ); if ( $outDir ) { // log changes - #file_put_contents( "$outDir/$wgDBname", "$currentFilePath $wgUploadDirectory/lost+found/$name\n", FILE_APPEND ); - #file_put_contents( "$outDir/$wgDBname", "$archivedFilePath $currentFilePath\n", FILE_APPEND ); + file_put_contents( "$outDir/$wgDBname", "$currentFilePath $wgUploadDirectory/lost+found/$name\n", FILE_APPEND ); + file_put_contents( "$outDir/$wgDBname", "$archivedFilePath $currentFilePath\n", FILE_APPEND ); } } } _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs