From 4e28aa1a81fdd86f5152125ce490d4541de1001b Mon Sep 17 00:00:00 2001 From: Sachith Hasaranga Seneviratne Date: Wed, 8 Jan 2014 19:08:18 +0530 Subject: [PATCH 1/2] (Feature Request 1466) Refactor PMA_Util::getLatestVersion() and PMA_sendErrorReport() to further reuse curl_handle option setting code. Signed-off-by: Sachith Seneviratne sachith500@gmail.com --- libraries/Util.class.php | 41 ++++++++++++++++++++-------------- libraries/error_report.lib.php | 13 ++--------- 2 files changed, 26 insertions(+), 28 deletions(-) diff --git a/libraries/Util.class.php b/libraries/Util.class.php index a67dc2554d..842acbeaf4 100644 --- a/libraries/Util.class.php +++ b/libraries/Util.class.php @@ -4184,6 +4184,29 @@ class PMA_Util } return $context; } + /** + * Updates an existing curl as necessary + * + * @param resource $curl_handle A curl_handle resource + * created by curl_init which should + * have several options set + * + * @return resource curl_handle with updated options + */ + public static function configureCurl(resource $curl_handle) + { + if (strlen($GLOBALS['cfg']['ProxyUrl'])) { + curl_setopt($curl_handle, CURLOPT_PROXY, $GLOBALS['cfg']['ProxyUrl']); + if (strlen($GLOBALS['cfg']['ProxyUser'])) { + curl_setopt( + $curl_handle, + CURLOPT_PROXYUSERPWD, + $GLOBALS['cfg']['ProxyUser'] . ':' . $GLOBALS['cfg']['ProxyPass'] + ); + } + } + return $curl_handle; + } /** * Returns information with latest version from phpmyadmin.net * @@ -4191,8 +4214,6 @@ class PMA_Util */ public static function getLatestVersion() { - global $cfg; - // wait 3s at most for server response, it's enough to get information // from a working server $connection_timeout = 3; @@ -4223,21 +4244,7 @@ class PMA_Util ); } else if (function_exists('curl_init')) { $curl_handle = curl_init($file); - if (strlen($cfg['ProxyUrl'])) { - curl_setopt( - $curl_handle, - CURLOPT_PROXY, - $cfg['ProxyUrl'] - ); - if (strlen($cfg['ProxyUser'])) { - curl_setopt( - $curl_handle, - CURLOPT_PROXYUSERPWD, - $cfg['ProxyUser'] - . ':' . $cfg['ProxyPass'] - ); - } - } + $curl_handle = PMA_Util::configureCurl($curl_handle); curl_setopt( $curl_handle, CURLOPT_HEADER, diff --git a/libraries/error_report.lib.php b/libraries/error_report.lib.php index 50c04caa74..fd35956f3f 100644 --- a/libraries/error_report.lib.php +++ b/libraries/error_report.lib.php @@ -7,7 +7,7 @@ */ /* - * Include for handleContext (in sendErrorReport. + * Include for handleContext() and configureCurl in PMA_sendErrorReport() */ require_once 'libraries/Util.class.php'; @@ -151,16 +151,7 @@ function PMA_sendErrorReport($report) } $curl_handle = curl_init(SUBMISSION_URL); - if (strlen($GLOBALS['cfg']['ProxyUrl'])) { - curl_setopt($curl_handle, CURLOPT_PROXY, $GLOBALS['cfg']['ProxyUrl']); - if (strlen($GLOBALS['cfg']['ProxyUser'])) { - curl_setopt( - $curl_handle, - CURLOPT_PROXYUSERPWD, - $GLOBALS['cfg']['ProxyUser'] . ':' . $GLOBALS['cfg']['ProxyPass'] - ); - } - } + $curl_handle = PMA_Util::configureCurl($curl_handle); curl_setopt($curl_handle, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($curl_handle, CURLOPT_HTTPHEADER, array('Expect:')); curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $data_string); From f405caa82a75a15f67acc98095f745a82bfc9eef Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Wed, 8 Jan 2014 09:25:55 -0500 Subject: [PATCH 2/2] ChangeLog entry for rfe 1466 Signed-off-by: Marc Delisle --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 37f831b4e5..2133107389 100644 --- a/ChangeLog +++ b/ChangeLog @@ -14,6 +14,7 @@ phpMyAdmin - ChangeLog + rfe #1478 Make Column Headings Sticky + rfe #1480 Enhance privileges initials table + rfe #1472 [interface] Break "Edit privileges" with sub-menus ++ rfe #1466 Minor refactoring required 4.1.5.0 (not yet released) - bug #3780 Allow aborting loading pages