From 0d1407f178dcd8cf97de424b3611b51043f08377 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Sat, 18 Feb 2012 14:43:05 +0530 Subject: [PATCH] bug #3486970 [import] Exception on XML import --- ChangeLog | 1 + libraries/Error.class.php | 3 ++- libraries/common.lib.php | 17 +++++++++++++++++ libraries/import/xml.php | 2 +- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index e41337523..7bcd2ddbd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,7 @@ phpMyAdmin - ChangeLog ====================== 3.4.11.0 (not yet released) +- bug #3486970 [import] Exception on XML import 3.4.10.0 (2012-02-14) - bug #3460090 [interface] TextareaAutoSelect feature broken diff --git a/libraries/Error.class.php b/libraries/Error.class.php index 595799be4..dd9c2a709 100644 --- a/libraries/Error.class.php +++ b/libraries/Error.class.php @@ -169,13 +169,14 @@ class PMA_Error extends PMA_Message */ public function getHash() { + $backtrace = PMA_isSerializable($this->getBacktrace()) ? serialize($this->getBacktrace()) : ''; if (null === $this->_hash) { $this->_hash = md5( $this->getNumber() . $this->getMessage() . $this->getFile() . $this->getLine() . - serialize($this->getBacktrace()) + $backtrace ); } diff --git a/libraries/common.lib.php b/libraries/common.lib.php index c2ea57ee9..976fabbd2 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -3020,4 +3020,21 @@ function PMA_buildActionTitles() { $titles['Edit'] = PMA_getIcon('b_edit.png', __('Edit'), true); return $titles; } + +/** + * Determines whether a variable is serializable. + * + * @param object $var object which needs to be checked for serializability + * + * @return whether the object is serializable. + */ +function PMA_isSerializable($var) +{ + try { + serialize($var); + return true; + } catch(Exception $e) { + return false; + } +} ?> diff --git a/libraries/import/xml.php b/libraries/import/xml.php index 0afbd15ae..5aa2b5959 100644 --- a/libraries/import/xml.php +++ b/libraries/import/xml.php @@ -186,7 +186,7 @@ $data_present = false; /** * Only attempt to analyze/collect data if there is data present */ -if (@count($xml->children())) { +if ($xml && @$xml->count()) { $data_present = true; /**