From c5a7c0517d51e749cfc562bf34bb59f5f356035c Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Wed, 17 Aug 2011 22:42:49 +0000 Subject: [PATCH] More wikia upstreaming --- includes/ImageGallery.php | 4 ++-- includes/XmlTypeCheck.php | 31 ++++++++++++++++++------------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/includes/ImageGallery.php b/includes/ImageGallery.php index 4d5f067ca7..8d3b6d6dac 100644 --- a/includes/ImageGallery.php +++ b/includes/ImageGallery.php @@ -28,9 +28,9 @@ class ImageGallery { * Contextual title, used when images are being screened * against the bad image list */ - private $contextTitle = false; + protected $contextTitle = false; - private $mAttribs = array(); + protected $mAttribs = array(); /** * Fixed margins diff --git a/includes/XmlTypeCheck.php b/includes/XmlTypeCheck.php index 78dd259dd5..be286f8e73 100644 --- a/includes/XmlTypeCheck.php +++ b/includes/XmlTypeCheck.php @@ -6,7 +6,7 @@ class XmlTypeCheck { * well-formed XML. Note that this doesn't check schema validity. */ public $wellFormed = false; - + /** * Will be set to true if the optional element filter returned * a match at some point. @@ -31,7 +31,7 @@ class XmlTypeCheck { $this->filterCallback = $filterCallback; $this->run( $file ); } - + /** * Get the root element. Simple accessor to $rootElement * @@ -52,21 +52,26 @@ class XmlTypeCheck { xml_set_element_handler( $parser, array( $this, 'rootElementOpen' ), false ); - $file = fopen( $fname, "rb" ); - do { - $chunk = fread( $file, 32768 ); - $ret = xml_parse( $parser, $chunk, feof( $file ) ); - if( $ret == 0 ) { - // XML isn't well-formed! + if ( file_exists( $fname ) ) { + $file = fopen( $fname, "rb" ); + if ( $file ) { + do { + $chunk = fread( $file, 32768 ); + $ret = xml_parse( $parser, $chunk, feof( $file ) ); + if( $ret == 0 ) { + // XML isn't well-formed! + fclose( $file ); + xml_parser_free( $parser ); + return; + } + } while( !feof( $file ) ); + fclose( $file ); - xml_parser_free( $parser ); - return; } - } while( !feof( $file ) ); + } $this->wellFormed = true; - fclose( $file ); xml_parser_free( $parser ); } @@ -77,7 +82,7 @@ class XmlTypeCheck { */ private function rootElementOpen( $parser, $name, $attribs ) { $this->rootElement = $name; - + if( is_callable( $this->filterCallback ) ) { xml_set_element_handler( $parser, array( $this, 'elementOpen' ), false ); $this->elementOpen( $parser, $name, $attribs ); -- 2.20.1