52 $this->infiles = explode(
';', $infile );
53 $this->reader =
new XMLReader();
54 $infile = array_shift( $this->infiles );
55 if ( defined(
'LIBXML_PARSEHUGE' ) ) {
56 $this->reader->open( $infile,
null, LIBXML_PARSEHUGE );
58 $this->reader->open( $infile );
72 $page = intval( $page );
74 while ( $this->lastPage < $page && !$this->atEnd ) {
75 $this->
debug(
"BaseDump::prefetch at page $this->lastPage, looking for $page" );
78 if ( $this->lastPage > $page || $this->atEnd ) {
79 $this->
debug(
"BaseDump::prefetch already past page $page "
80 .
"looking for rev $rev [$this->lastPage, $this->lastRev]" );
84 while ( $this->lastRev < $rev && !$this->atEnd && !$this->atPageEnd ) {
85 $this->
debug(
"BaseDump::prefetch at page $this->lastPage, rev $this->lastRev, "
86 .
"looking for $page, $rev" );
89 if ( $this->lastRev ==
$rev && !$this->atEnd ) {
90 $this->
debug(
"BaseDump::prefetch hit on $page, $rev [$this->lastPage, $this->lastRev]" );
94 $this->
debug(
"BaseDump::prefetch already past rev $rev on page $page "
95 .
"[$this->lastPage, $this->lastRev]" );
111 if ( $this->
skipTo(
'page',
'mediawiki' ) ) {
112 if ( $this->
skipTo(
'id' ) ) {
115 $this->atPageEnd =
false;
119 if (
count( $this->infiles ) ) {
120 $infile = array_shift( $this->infiles );
121 $this->reader->open( $infile );
122 $this->atEnd =
false;
131 if ( $this->
skipTo(
'revision' ) ) {
132 if ( $this->
skipTo(
'id' ) ) {
136 $this->atPageEnd =
true;
157 if ( $this->atEnd ) {
160 while ( $this->reader->read() ) {
161 if ( $this->reader->nodeType == XMLReader::ELEMENT
162 && $this->reader->name ==
$name
166 if ( $this->reader->nodeType == XMLReader::END_ELEMENT
167 && $this->reader->name == $parent
169 $this->
debug(
"BaseDump::skipTo found </$parent> searching for <$name>" );
175 return $this->
close();
187 if ( $this->atEnd ) {
190 if ( $this->reader->isEmptyElement ) {
194 while ( $this->reader->read() ) {
195 switch ( $this->reader->nodeType ) {
196 case XMLReader::TEXT:
198 case XMLReader::SIGNIFICANT_WHITESPACE:
199 $buffer .= $this->reader->value;
201 case XMLReader::END_ELEMENT:
206 return $this->
close();
214 $this->reader->close();