API:
[lhc/web/wiklou.git] / maintenance / backupPrefetch.inc
index f40bc89..413247d 100644 (file)
@@ -1,5 +1,43 @@
 <?php
 
+// Some smart guy removed XMLReader's global constants from PHP 5.1
+// and replaced them with class constants. Breaking source compatibility
+// is SUPER awesome, and I love languages which do this constantly!
+$xmlReaderConstants = array(
+       "NONE",
+       "ELEMENT",
+       "ATTRIBUTE", 
+       "TEXT",
+       "CDATA",
+       "ENTITY_REF",
+       "ENTITY",
+       "PI",
+       "COMMENT",
+       "DOC",
+       "DOC_TYPE",
+       "DOC_FRAGMENT",
+       "NOTATION",
+       "WHITESPACE",
+       "SIGNIFICANT_WHITESPACE",
+       "END_ELEMENT",
+       "END_ENTITY",
+       "XML_DECLARATION",
+       "LOADDTD",
+       "DEFAULTATTRS",
+       "VALIDATE",
+       "SUBST_ENTITIES" );
+foreach( $xmlReaderConstants as $name ) {
+       $fullName = "XMLREADER_$name";
+       $newName = "XMLReader::$name";
+       if( !defined( $fullName ) ) {
+               if( defined( $newName ) ) {
+                       define( $fullName, constant( $newName ) );
+               } else {
+                       // broken or missing the extension...
+               }
+       }
+}
+
 /**
  * Readahead helper for making large MediaWiki data dumps;
  * reads in a previous XML dump to sequentially prefetch text
@@ -21,12 +59,12 @@ class BaseDump {
        var $atPageEnd = false;
        var $lastPage = 0;
        var $lastRev = 0;
-       
+
        function BaseDump( $infile ) {
                $this->reader = new XMLReader();
                $this->reader->open( $infile );
        }
-       
+
        /**
         * Attempts to fetch the text of a particular page revision
         * from the dump stream. May return null if the page is
@@ -59,13 +97,13 @@ class BaseDump {
                        return null;
                }
        }
-       
+
        function debug( $str ) {
                wfDebug( $str . "\n" );
                //global $dumper;
                //$dumper->progress( $str );
        }
-       
+
        /**
         * @access private
         */
@@ -80,7 +118,7 @@ class BaseDump {
                        $this->atEnd = true;
                }
        }
-       
+
        /**
         * @access private
         */
@@ -93,7 +131,7 @@ class BaseDump {
                        $this->atPageEnd = true;
                }
        }
-       
+
        /**
         * @access private
         */
@@ -101,7 +139,7 @@ class BaseDump {
                $this->skipTo( 'text' );
                return strval( $this->nodeContents() );
        }
-       
+
        /**
         * @access private
         */
@@ -122,7 +160,7 @@ class BaseDump {
                }
                return $this->close();
        }
-       
+
        /**
         * Shouldn't something like this be built-in to XMLReader?
         * Fetches text contents of the current element, assuming
@@ -151,7 +189,7 @@ class BaseDump {
                }
                return $this->close();
        }
-       
+
        /**
         * @access private
         */