ChgoChad / namecheap

Automatically exported from code.google.com/p/namecheap
0 stars 0 forks source link

Warnings with the usage of array_shift when using PHP 5.4.0 #25

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Install PHP 5.4.0
2. Go inside an ordered certificate as a user
3.

What is the expected output? 
Information about the certificate.
What do you see instead?
A PHP warning.

What version of the product are you using? On what operating system?
Linux, Centos 6

Please provide any additional information below.

Array_shift takes an argument array &array, so you can't pass the result of a 
function.

Here's the patch.
diff --git a/namecheapssl.php b/namecheapssl.php
index bc62909..5919af9 100755
--- a/namecheapssl.php
+++ b/namecheapssl.php
@@ -1877,8 +1877,8 @@ function namecheapssl_SSLStepThreeReissue($params) {
     if ('COMODO' == $sProviderName) {

         $_webServerTypes = namecheapssl_getWebServerTypes();
-
-        $params['configdata'] = 
unserialize(array_shift(mysql_fetch_assoc(mysql_query("SELECT configdata FROM 
`tblsslorders` WHERE serviceid='{$params['serviceid']}'"))));
+       $mysql_fetch_assoc = mysql_fetch_assoc(mysql_query("SELECT configdata 
FROM `tblsslorders` WHERE serviceid='{$params['serviceid']}'"));
+        $params['configdata'] = unserialize(array_shift($mysql_fetch_assoc));

         $requestParams = array(
             'CertificateID' => $cert['remoteid'],
@@ -2746,7 +2746,8 @@ function namecheapssl_save_debug_info($message, $command, 
$isResponse = false, $

     if (!empty($_SESSION['adminid'])) {
         $userid = $_SESSION["adminid"];
-        $username = array_shift(mysql_fetch_array(mysql_query("SELECT username 
FROM tbladmins WHERE id='$userid'")));
+       $mysql_fetch_array = mysql_fetch_array(mysql_query("SELECT username 
FROM tbladmins WHERE id='$userid'"));
+        $username = array_shift($mysql_fetch_array);
     } else {
         $userid = $_SESSION['uid'];
         $username = 'client';
@@ -2779,7 +2780,8 @@ function namecheapssl_log($action, $messageKey, $args = 
null, $serviceId = 0) {

     if (!empty($_SESSION['adminid'])) {
         $userid = $_SESSION["adminid"];
-        $username = array_shift(mysql_fetch_array(mysql_query("SELECT username 
FROM tbladmins WHERE id='$userid'")));
+       $mysql_fetch_array = mysql_fetch_array(mysql_query("SELECT username 
FROM tbladmins WHERE id='$userid'"));
+        $username = array_shift($mysql_fetch_array);
     }
     if (!empty($_SESSION['uid'])) {
         $userid = $_SESSION['uid'];

Original issue reported on code.google.com by jose...@gmail.com on 31 Mar 2014 at 2:18