r96275 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96274‎ | r96275 | r96276 >
Date:11:16, 5 September 2011
Author:catrope
Status:ok (Comments)
Tags:
Comment:
Fixes for r95260:
* Use protected instead of var
* Move documentation of closeRenameAndReopen() to parent class. Add a TODO for the other undocumented methods introduced in r95260
* Use the correct method name in the exceptions by using __METHOD__; messages were copypasted from one method to the other without changing anything. Also fix a typo ("argumnts")
* Minor coding style bit, will commit more style fixes in a minute
Modified paths:
  • /trunk/phase3/includes/Export.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Export.php
@@ -354,9 +354,7 @@
355355 * @ingroup Dump
356356 */
357357 class XmlDumpWriter {
358 - var $firstPageWritten = 0;
359 - var $lastPageWritten = 0;
360 - var $pageInProgress = 0;
 358+ protected $firstPageWritten = 0, $lastPageWritten = 0, $pageInProgress = 0;
361359
362360 /**
363361 * Returns the export schema version.
@@ -482,7 +480,7 @@
483481 */
484482 function closePage() {
485483 return " </page>\n";
486 - if (! $this->firstPageWritten) {
 484+ if ( !$this->firstPageWritten ) {
487485 $this->firstPageWritten = $this->pageInProgress;
488486 }
489487 $this->lastPageWritten = $this->pageInProgress;
@@ -700,18 +698,28 @@
701699 print $string;
702700 }
703701
 702+ /**
 703+ * Close the old file, move it to a specified name,
 704+ * and reopen new file with the old name. Use this
 705+ * for writing out a file in multiple pieces
 706+ * at specified checkpoints (e.g. every n hours).
 707+ * @param $newname mixed File name. May be a string or an array with one element
 708+ */
704709 function closeRenameAndReopen( $newname ) {
705710 return;
706711 }
707712
 713+ // TODO: document
708714 function closeAndRename( $newname ) {
709715 return;
710716 }
711717
 718+ // TODO: document
712719 function rename( $newname ) {
713720 return;
714721 }
715722
 723+ // TODO: document
716724 function getFilename() {
717725 return NULL;
718726 }
@@ -734,16 +742,10 @@
735743 fputs( $this->handle, $string );
736744 }
737745
738 - /**
739 - * Close the old file, move it to a specified name,
740 - * and reopen new file with the old name. Use this
741 - * for writing out a file in multiple pieces
742 - * at specified checkpoints (e.g. every n hours).
743 - */
744746 function closeRenameAndReopen( $newname ) {
745747 if ( is_array($newname) ) {
746748 if (count($newname) > 1) {
747 - throw new MWException("Export closeRenameAndReopen: passed multiple argumnts for rename of single file\n");
 749+ throw new MWException(__METHOD__ . ": passed multiple arguments for rename of single file\n");
748750 }
749751 else {
750752 $newname = $newname[0];
@@ -759,7 +761,7 @@
760762 function closeAndRename( $newname ) {
761763 if ( is_array($newname) ) {
762764 if (count($newname) > 1) {
763 - throw new MWException("Export closeRenameAndReopen: passed multiple argumnts for rename of single file\n");
 765+ throw new MWException(__METHOD__ . ": passed multiple arguments for rename of single file\n");
764766 }
765767 else {
766768 $newname = $newname[0];
@@ -774,7 +776,7 @@
775777 function rename( $newname ) {
776778 if ( is_array($newname) ) {
777779 if (count($newname) > 1) {
778 - throw new MWException("Export closeRenameAndReopen: passed multiple argumnts for rename of single file\n");
 780+ throw new MWException(__METHOD__ . ": passed multiple arguments for rename of single file\n");
779781 }
780782 else {
781783 $newname = $newname[0];
@@ -797,7 +799,7 @@
798800 * @ingroup Dump
799801 */
800802 class DumpPipeOutput extends DumpFileOutput {
801 - var $command;
 803+ protected $command, $filename;
802804
803805 function __construct( $command, $file = null ) {
804806 if ( !is_null( $file ) ) {
@@ -825,7 +827,7 @@
826828 function closeRenameAndReopen( $newname ) {
827829 if ( is_array($newname) ) {
828830 if (count($newname) > 1) {
829 - throw new MWException("Export closeRenameAndReopen: passed multiple argumnts for rename of single file\n");
 831+ throw new MWException(__METHOD__ . ": passed multiple arguments for rename of single file\n");
830832 }
831833 else {
832834 $newname = $newname[0];
@@ -844,7 +846,7 @@
845847 function closeAndRename( $newname ) {
846848 if ( is_array($newname) ) {
847849 if (count($newname) > 1) {
848 - throw new MWException("Export closeRenameAndReopen: passed multiple argumnts for rename of single file\n");
 850+ throw new MWException(__METHOD__ . ": passed multiple arguments for rename of single file\n");
849851 }
850852 else {
851853 $newname = $newname[0];
@@ -861,7 +863,7 @@
862864 function rename( $newname ) {
863865 if ( is_array($newname) ) {
864866 if (count($newname) > 1) {
865 - throw new MWException("Export closeRenameAndReopen: passed multiple argumnts for rename of single file\n");
 867+ throw new MWException(__METHOD__ . ": passed multiple arguments for rename of single file\n");
866868 }
867869 else {
868870 $newname = $newname[0];
@@ -898,7 +900,7 @@
899901 * @ingroup Dump
900902 */
901903 class Dump7ZipOutput extends DumpPipeOutput {
902 - var $filename;
 904+ protected $filename;
903905
904906 function __construct( $file ) {
905907 $command = "7za a -bd -si " . wfEscapeShellArg( $file );
@@ -912,7 +914,7 @@
913915 function closeRenameAndReopen( $newname ) {
914916 if ( is_array($newname) ) {
915917 if (count($newname) > 1) {
916 - throw new MWException("Export closeRenameAndReopen: passed multiple argumnts for rename of single file\n");
 918+ throw new MWException(__METHOD__ . ": passed multiple arguments for rename of single file\n");
917919 }
918920 else {
919921 $newname = $newname[0];
@@ -931,7 +933,7 @@
932934 function closeAndRename( $newname ) {
933935 if ( is_array($newname) ) {
934936 if (count($newname) > 1) {
935 - throw new MWException("Export closeRenameAndReopen: passed multiple argumnts for rename of single file\n");
 937+ throw new MWException(__METHOD__ . ": passed multiple arguments for rename of single file\n");
936938 }
937939 else {
938940 $newname = $newname[0];
@@ -947,7 +949,7 @@
948950 function rename( $newname ) {
949951 if ( is_array($newname) ) {
950952 if (count($newname) > 1) {
951 - throw new MWException("Export closeRenameAndReopen: passed multiple argumnts for rename of single file\n");
 953+ throw new MWException(__METHOD__ . ": passed multiple arguments for rename of single file\n");
952954 }
953955 else {
954956 $newname = $newname[0];

Follow-up revisions

RevisionCommit summaryAuthorDate
r96378Fix parse error in r96275catrope22:17, 6 September 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r95260add functions that support close and rename of output files as they are being...ariel22:01, 22 August 2011

Comments

#Comment by Platonides (talk | contribs)   14:57, 5 September 2011

Fatal error: Access level to DumpPipeOutput::$filename must be public (as in class DumpFileOutput) in ./includes/Export.php on line 870

(wasn't a hook supposed to be in place now?)

Status & tagging log