File: 1004_fix-php-warnings.patch

package info (click to toggle)
slbackup-php 0.4.5-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 588 kB
  • sloc: php: 983; makefile: 92; sh: 48
file content (74 lines) | stat: -rw-r--r-- 2,799 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
From: Guido Berhoerster <guido@berhoerster.name>
Subject: Fix PHP warnings
Abstract:
 Fix use of uninitialized variables and non-existing array keys.
Forwarded: https://salsa.debian.org/debian-edu/upstream/slbackup-php/-/commit/1a6c44e7ec3003d5665d85253d57ab242dff4f0b

---
 src/index.php | 3 +++
 1 file changed, 3 insertions(+)

--- slbackup-php.orig/src/index.php
+++ slbackup-php/src/index.php
@@ -475,6 +475,8 @@ global $backuphost, $backupuser, $backup
 function readconf ($passwd) {
 global $backuphost, $backupuser, $backupconf, $ssh_options, $ssh_askpass ;
 
+    $config = array() ;
+
     $cmd = sprintf ("ssh %s %s@%s cat %s", 
    		     $ssh_options, $backupuser, 
 		     $backuphost, $backupconf) ; 
@@ -556,7 +558,9 @@ global $backuphost, $backupuser, $logfil
 	fprintf ($pipes[0], "%s\n", $passwd) ; 
 	fclose ($pipes[0]) ; 
 	while ($line = fgets ($pipes[1], 1024)) {
-	    list ($timestamp, $info) = explode (" - ", trim($line)) ; 
+	    $parts = explode (" - ", trim($line)) ;
+	    $timestamp = $parts[0];
+	    $info = $parts[1] ?? null;
 	    if ($info == "Starting slbackup:") 
 	        $log["start"] = strtotime($timestamp) ; 
 	    elseif ($info == "Finished slbackup.")
@@ -611,6 +615,8 @@ foreach ($_COOKIE as $key => $value) {
 }
 
 # Fetch arguments passed as the script is executed
+$nonhttps = '' ;
+$submit = '';
 foreach ($arguments as $key => $value) {
     switch ($key) {
         case "smarty_templ": 
@@ -901,7 +907,7 @@ switch ($submit) {
     case "restorelocation":
 	$smarty->assign ('loc', $loc) ; 
 	$smarty->assign ('location', $newconf["location"]) ; 
-	$smarty->assign ('sub', $newconf["sub"]) ; 
+	$smarty->assign ('sub', $newconf["sub"] ?? '') ; 
     case "restoreclient":
     case "restore":
 	$clients = array_keys($config["clients"]) ; 
@@ -916,7 +922,7 @@ switch ($submit) {
     case "maint":
 	$clients = array_keys($config["clients"]) ; 
 	$smarty->assign ('clients', $clients) ; 
-	$smarty->assign ('client', $client) ; 
+	$smarty->assign ('client', $client ?? '') ; 
 	$smarty->display ('maint.tpl') ; 
         break ; 
     case "config":
--- slbackup-php.orig/src/functions.php
+++ slbackup-php/src/functions.php
@@ -24,9 +24,9 @@ function loadConfig () {
 
     @include_once ("/etc/slbackup-php/config.php") ;
 
-    if (empty ($nonhttps))       $nonhttps       = $_COOKIE ['nonhttps'] ;
-    if (empty ($smarty_templ))   $smarty_templ   = $_COOKIE ['smarty_templ'] ;
-    if (empty ($smarty_compile)) $smarty_compile = $_COOKIE ['smarty_compile'] ;
+    $nonhttps ??= $_COOKIE ['nonhttps'] ?? '' ;
+    $smarty_templ ??= $_COOKIE ['smarty_templ'] ?? null ;
+    $smarty_compile ??= $_COOKIE ['smarty_compile'] ?? null ;
 
     if (empty ($backuphost)) $backuphost="localhost" ;
     if (empty ($backupuser)) $backupuser="root" ;