[BUGFIX] Make sure XML parser is created everytime when needed 66/18966/2
authorChristian Kuhn <lolli@schwarzbu.ch>
Sat, 16 Mar 2013 00:25:29 +0000 (01:25 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 16 Mar 2013 00:30:27 +0000 (01:30 +0100)
Currently, EM's MirrorXmlPushParser, which is based on ext/xml,
is not properly working. The constructor creates the parser and
within parseXML() method the parser resource is freed.
However, when clicking on retrieve/update button method
parseXML() is invoked multiple times which makes subsequent calls
fail.

Creating the parser is now done within parseXML() method.

Change-Id: I7c6c15f65d08fb0264d7d66cc584cbe7ff423b45
Resolves: #25292
Releases: 6.1, 6.0, 4.7, 4.5
Reviewed-on: https://review.typo3.org/18966
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/extensionmanager/Classes/Utility/Parser/AbstractXmlParser.php
typo3/sysext/extensionmanager/Classes/Utility/Parser/ExtensionXmlPullParser.php
typo3/sysext/extensionmanager/Classes/Utility/Parser/ExtensionXmlPushParser.php
typo3/sysext/extensionmanager/Classes/Utility/Parser/MirrorXmlPullParser.php
typo3/sysext/extensionmanager/Classes/Utility/Parser/MirrorXmlPushParser.php

index 8f572cc..698a8e4 100644 (file)
@@ -75,7 +75,12 @@ abstract class AbstractXmlParser {
         */
        abstract public function parseXml($file);
 
+       /**
+        * Create required parser
+        *
+        * @return  void
+        */
+       abstract protected function createParser();
 }
 
-
 ?>
\ No newline at end of file
index d065ae0..ad87771 100644 (file)
@@ -51,9 +51,15 @@ class ExtensionXmlPullParser extends \TYPO3\CMS\Extensionmanager\Utility\Parser\
         */
        public function __construct() {
                $this->requiredPhpExtensions = 'xmlreader';
-               if ($this->isAvailable()) {
-                       $this->objXml = new \XMLReader();
-               }
+       }
+
+       /**
+        * Create required parser
+        *
+        * @return  void
+        */
+       protected function createParser() {
+               $this->objXml = new \XMLReader();
        }
 
        /**
@@ -64,6 +70,7 @@ class ExtensionXmlPullParser extends \TYPO3\CMS\Extensionmanager\Utility\Parser\
         * @throws \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException in case of parser error
         */
        public function parseXml($file) {
+               $this->createParser();
                if (!(is_object($this->objXml) && get_class($this->objXml) == 'XMLReader')) {
                        throw new \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException('Unable to create XML parser.', 1342640540);
                }
index 38f302b..0974c4a 100644 (file)
@@ -62,10 +62,16 @@ class ExtensionXmlPushParser extends \TYPO3\CMS\Extensionmanager\Utility\Parser\
         */
        public function __construct() {
                $this->requiredPhpExtensions = 'xml';
-               if ($this->isAvailable()) {
-                       $this->objXml = xml_parser_create();
-                       xml_set_object($this->objXml, $this);
-               }
+       }
+
+       /**
+        * Create required parser
+        *
+        * @return  void
+        */
+       protected function createParser() {
+               $this->objXml = xml_parser_create();
+               xml_set_object($this->objXml, $this);
        }
 
        /**
@@ -76,6 +82,7 @@ class ExtensionXmlPushParser extends \TYPO3\CMS\Extensionmanager\Utility\Parser\
         * @throws \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException in case of parse errors
         */
        public function parseXml($file) {
+               $this->createParser();
                if (!is_resource($this->objXml)) {
                        throw new \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException('Unable to create XML parser.', 1342640663);
                }
index 6f44ae7..4bdacd4 100644 (file)
@@ -50,9 +50,15 @@ class MirrorXmlPullParser extends \TYPO3\CMS\Extensionmanager\Utility\Parser\Abs
         */
        public function __construct() {
                $this->requiredPhpExtensions = 'xmlreader';
-               if ($this->isAvailable()) {
-                       $this->objXml = new \XMLReader();
-               }
+       }
+
+       /**
+        * Create required parser
+        *
+        * @return  void
+        */
+       protected function createParser() {
+               $this->objXml = new \XMLReader();
        }
 
        /**
@@ -63,6 +69,7 @@ class MirrorXmlPullParser extends \TYPO3\CMS\Extensionmanager\Utility\Parser\Abs
         * @throws \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException in case of XML parser errors
         */
        public function parseXml($file) {
+               $this->createParser();
                if (!(is_object($this->objXml) && get_class($this->objXml) == 'XMLReader')) {
                        throw new \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException('Unable to create XML parser.', 1342640820);
                }
index 0b734cd..5e733df 100644 (file)
@@ -52,10 +52,16 @@ class MirrorXmlPushParser extends \TYPO3\CMS\Extensionmanager\Utility\Parser\Abs
         */
        public function __construct() {
                $this->requiredPhpExtensions = 'xml';
-               if ($this->isAvailable()) {
-                       $this->objXml = xml_parser_create();
-                       xml_set_object($this->objXml, $this);
-               }
+       }
+
+       /**
+        * Create required parser
+        *
+        * @return  void
+        */
+       protected function createParser() {
+               $this->objXml = xml_parser_create();
+               xml_set_object($this->objXml, $this);
        }
 
        /**
@@ -66,6 +72,7 @@ class MirrorXmlPushParser extends \TYPO3\CMS\Extensionmanager\Utility\Parser\Abs
         * @throws \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException in case of XML parser errors
         */
        public function parseXml($file) {
+               $this->createParser();
                if (!is_resource($this->objXml)) {
                        throw new \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException('Unable to create XML parser.', 1342641009);
                }