From fe918166cc1325c022197c3124cbff74a3909c1b Mon Sep 17 00:00:00 2001 From: Ivan Tcholakov Date: Tue, 13 Oct 2009 18:35:07 +0300 Subject: [PATCH 1/2] Bug #5418 - Fixing some PHP4 style code in PEAR/QuickForm, so deprecation messages be shown on PHP 5.3. --- main/inc/lib/pear/HTML/QuickForm.php | 15 ++++++++++++--- .../lib/pear/HTML/QuickForm/RuleRegistry.php | 5 ++++- main/inc/lib/pear/HTML/QuickForm/group.php | 5 ++++- main/inc/lib/pear/Pager/Common.php | 18 ++++++++++++++---- 4 files changed, 34 insertions(+), 9 deletions(-) diff --git a/main/inc/lib/pear/HTML/QuickForm.php b/main/inc/lib/pear/HTML/QuickForm.php index c10e83e3ff..40f369e10b 100755 --- a/main/inc/lib/pear/HTML/QuickForm.php +++ b/main/inc/lib/pear/HTML/QuickForm.php @@ -565,7 +565,10 @@ class HTML_QuickForm extends HTML_Common { $className = $GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES'][$type][1]; $includeFile = $GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES'][$type][0]; include_once($includeFile); - $elementObject =& new $className(); + // Suppressing a deprecation warning on PHP 5.3 + //$elementObject =& new $className(); + $elementObject = new $className(); + // for ($i = 0; $i < 5; $i++) { if (!isset($args[$i])) { $args[$i] = null; @@ -1664,7 +1667,10 @@ class HTML_QuickForm extends HTML_Common { { if (!isset($GLOBALS['_HTML_QuickForm_default_renderer'])) { include_once('HTML/QuickForm/Renderer/Default.php'); - $GLOBALS['_HTML_QuickForm_default_renderer'] =& new HTML_QuickForm_Renderer_Default(); + // Suppressing a deprecation warning on PHP 5.3 + //$GLOBALS['_HTML_QuickForm_default_renderer'] =& new HTML_QuickForm_Renderer_Default(); + $GLOBALS['_HTML_QuickForm_default_renderer'] = new HTML_QuickForm_Renderer_Default(); + // } return $GLOBALS['_HTML_QuickForm_default_renderer']; } // end func defaultRenderer @@ -1821,7 +1827,10 @@ class HTML_QuickForm extends HTML_Common { function toArray($collectHidden = false) { include_once 'HTML/QuickForm/Renderer/Array.php'; - $renderer =& new HTML_QuickForm_Renderer_Array($collectHidden); + // Suppressing a deprecation warning on PHP 5.3 + //$renderer =& new HTML_QuickForm_Renderer_Array($collectHidden); + $renderer = new HTML_QuickForm_Renderer_Array($collectHidden); + // $this->accept($renderer); return $renderer->toArray(); } // end func toArray diff --git a/main/inc/lib/pear/HTML/QuickForm/RuleRegistry.php b/main/inc/lib/pear/HTML/QuickForm/RuleRegistry.php index d8d7ff4b56..a58b80ba5b 100755 --- a/main/inc/lib/pear/HTML/QuickForm/RuleRegistry.php +++ b/main/inc/lib/pear/HTML/QuickForm/RuleRegistry.php @@ -115,7 +115,10 @@ class HTML_QuickForm_RuleRegistry if (!empty($path)) { include_once($path); } - $this->_rules[$class] =& new $class(); + // Suppressing a deprecation warning on PHP 5.3 + //$this->_rules[$class] =& new $class(); + $this->_rules[$class] = new $class(); + // } $this->_rules[$class]->setName($ruleName); return $this->_rules[$class]; diff --git a/main/inc/lib/pear/HTML/QuickForm/group.php b/main/inc/lib/pear/HTML/QuickForm/group.php index 4daacf46ea..b79eea6f85 100755 --- a/main/inc/lib/pear/HTML/QuickForm/group.php +++ b/main/inc/lib/pear/HTML/QuickForm/group.php @@ -290,7 +290,10 @@ class HTML_QuickForm_group extends HTML_QuickForm_element function toHtml() { include_once('HTML/QuickForm/Renderer/Default.php'); - $renderer =& new HTML_QuickForm_Renderer_Default(); + // Suppressing a deprecation warning on PHP 5.3 + //$renderer =& new HTML_QuickForm_Renderer_Default(); + $renderer = new HTML_QuickForm_Renderer_Default(); + // $renderer->setElementTemplate('{element}'); $this->accept($renderer); return $renderer->toHtml(); diff --git a/main/inc/lib/pear/Pager/Common.php b/main/inc/lib/pear/Pager/Common.php index 7766a6541e..23c2a16264 100755 --- a/main/inc/lib/pear/Pager/Common.php +++ b/main/inc/lib/pear/Pager/Common.php @@ -1149,7 +1149,10 @@ class Pager_Common function getPerPageSelectBox($start=5, $end=30, $step=5, $showAllData=false, $extraParams=array()) { require_once 'Pager/HtmlWidgets.php'; - $widget =& new Pager_HtmlWidgets($this); + // Suppressing a deprecation warning on PHP 5.3 + //$widget =& new Pager_HtmlWidgets($this); + $widget = new Pager_HtmlWidgets($this); + // return $widget->getPerPageSelectBox($start, $end, $step, $showAllData, $extraParams); } @@ -1173,7 +1176,10 @@ class Pager_Common function getPageSelectBox($params = array(), $extraAttributes = '') { require_once 'Pager/HtmlWidgets.php'; - $widget =& new Pager_HtmlWidgets($this); + // Suppressing a deprecation warning on PHP 5.3 + //$widget =& new Pager_HtmlWidgets($this); + $widget = new Pager_HtmlWidgets($this); + // return $widget->getPageSelectBox($params, $extraAttributes); } @@ -1428,8 +1434,12 @@ class Pager_Common session_write_close(); } - $this->_spacesBefore = str_repeat(' ', $this->_spacesBeforeSeparator); - $this->_spacesAfter = str_repeat(' ', $this->_spacesAfterSeparator); + // Suppressing warnings on PHP 5.3 + //$this->_spacesBefore = str_repeat(' ', $this->_spacesBeforeSeparator); + //$this->_spacesAfter = str_repeat(' ', $this->_spacesAfterSeparator); + $this->_spacesBefore = str_repeat(' ', intval($this->_spacesBeforeSeparator)); + $this->_spacesAfter = str_repeat(' ', intval($this->_spacesAfterSeparator)); + // if (isset($_REQUEST[$this->_urlVar]) && empty($options['currentPage'])) { $this->_currentPage = (int)$_REQUEST[$this->_urlVar]; From cbadc3fc5cfebe4fe890d0a077a6c17c905956a3 Mon Sep 17 00:00:00 2001 From: Ivan Tcholakov Date: Tue, 13 Oct 2009 18:37:47 +0300 Subject: [PATCH 2/2] Bug #5418 - Suppressing all PHP 5.3 deprecation messages for "Test Server" system mode. --- main/inc/global.inc.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main/inc/global.inc.php b/main/inc/global.inc.php index bcd3c7b143..6d60b87d77 100755 --- a/main/inc/global.inc.php +++ b/main/inc/global.inc.php @@ -251,7 +251,11 @@ if (api_get_setting('server_type') == 'test') { - only do addslashes on $_GET and $_POST -------------------------------------------- */ - error_reporting(E_ALL & ~E_NOTICE); + if (IS_PHP_53) { + error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED); + } else { + error_reporting(E_ALL & ~E_NOTICE); + } //error_reporting(E_ALL); //Addslashes to all $_GET variables