patch drupal's session handler for php8
[plewww.git] / drupal-hacks / patch-session-inc.sh
diff --git a/drupal-hacks/patch-session-inc.sh b/drupal-hacks/patch-session-inc.sh
new file mode 100755 (executable)
index 0000000..1cc8708
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+# for php8; the handler attached to session_destroy must now return a boolean
+# the patched function is a one-liner
+# so we find its declaration, go down one line (+), and then add a line
+
+readonly filetopatch=/var/www/html/includes/session.inc
+
+# do not patch twice
+if ! grep -q 'patch-session_destroy' $filetopatch >& /dev/null; then
+    ed $filetopatch << EOF
+/function sess_destroy
++
+a
+  return TRUE; // patch-session_destroy for php8
+.
+wq
+EOF
+fi