Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP Warning: Trying to access array offset on value of type bool in colinmollenhour/credis/Client.php on line 1156 #187

Open
xtremevision opened this issue May 11, 2024 · 2 comments

Comments

@xtremevision
Copy link

Hi,

Using Magento 2.4.6-p2 open source and colinmollenhour/credis v1.16.0. Using a command line script I am getting this error:

PHP Warning: Trying to access array offset on value of type bool in colinmollenhour/credis/Client.php on line 1156

Not sure why this is happening. Have not debugged in depth, but

$execResponse = array_pop($response);

is actually false, so doing:

                        if(!empty($execResponse))
                        {
                            foreach ($queuedResponses as $key => $command) {
                                list($name, $arguments) = $command;
                                $response[] = $this->decode_reply($name, $execResponse[$key], $arguments);
                            }    
                        }

suppresses the warning.

Michael.

@xtremevision
Copy link
Author

Suggested patch:

index b6f2eb5..37dfce5 100644
--- a/credis/Client.php
+++ b/credis/Client.php
@@ -1151,9 +1151,12 @@
 
                         if ($this->isMulti) {
                             $execResponse = array_pop($response);
-                            foreach ($queuedResponses as $key => $command) {
-                                list($name, $arguments) = $command;
-                                $response[] = $this->decode_reply($name, $execResponse[$key], $arguments);
+                            if(!empty($execResponse))
+                            {
+                                foreach ($queuedResponses as $key => $command) {
+                                    list($name, $arguments) = $command;
+                                    $response[] = $this->decode_reply($name, $execResponse[$key], $arguments);
+                                }    
                             }
                         }
                     } catch (CredisException $e) {

@colinmollenhour
Copy link
Owner

Please submit a PR so we can see if it passes the unit tests. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants