File: 1009_plugin-callHook-always_output_shell_debugging_msgs.patch

package info (click to toggle)
gosa 2.8~git20230203.10abe45%2Bdfsg-19
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 33,108 kB
  • sloc: php: 32,102; javascript: 10,836; pascal: 3,776; xml: 3,135; sh: 852; python: 162; makefile: 45; perl: 2
file content (36 lines) | stat: -rw-r--r-- 2,240 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
--- a/include/class_plugin.inc
+++ b/include/class_plugin.inc
@@ -1725,12 +1725,19 @@
                   // Close the process and check its return value
                   $returnCode = proc_close($process);
                   $returnOutput = preg_split("/\n/", $arr,0,PREG_SPLIT_NO_EMPTY);
+                  if (!is_array($returnOutput)) {
+                    $returnOutput = array(); // Make sure returnOutput is always an array.
+                  }
+
                   $errorOutput = preg_split("/\n/",$err,0,PREG_SPLIT_NO_EMPTY);
+                  if (!is_array($errorOutput)) {
+                    $errorOutput = array(); // Make sure returnOutput is always an array.
+                  }
               }
 
               if($returnCode != 0){
-                  @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__, $command, "Execution failed code: ".$returnCode);
-                  @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__, $command, "Result: ".$err);
+                  @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__, $command, "Execution failed code: " . $returnCode);
+                  @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__, $command, "Failure result: " . $err);
                   if($displayErrors){
                       $message= msgPool::cmdexecfailed($cmd,$command, get_class($plugin));
                       msg_dialog::display(_("Error"), $message, ERROR_DIALOG);
@@ -1738,8 +1745,9 @@
                       $message= msgPool::cmdexecfailed($cmd,"...", get_class($plugin));
                       msg_dialog::display(_("Error"), $message, ERROR_DIALOG);
                   }
-              }elseif(is_array($arr)){
-                  @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__, $command, "Result: ".$arr);
+              } else {
+                @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__, $command, "Success result (stdout):<br>" . implode("<br>", $returnOutput));
+                @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__, $command, "Success result (stderr):<br>" . implode("<br>", $errorOutput));
               }
           } elseif($displayErrors) {
               $message= msgPool::cmdinvalid($cmd,$command, get_class($plugin));