From 36b60d1af0f4869de2b0e30e0f52e2e82510642a Mon Sep 17 00:00:00 2001 From: "Stephen J. Carnam" Date: Fri, 27 Oct 2023 18:26:15 -0700 Subject: [PATCH] backup optional --- hooks/pluginable.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hooks/pluginable.php b/hooks/pluginable.php index 8b9b250..f007bf6 100644 --- a/hooks/pluginable.php +++ b/hooks/pluginable.php @@ -448,8 +448,9 @@ public function log( $msg ) { * @param string $search The search string. * @param string $replace The replace string. * @param boolean $retry_tabs If true, retry with spaces instead of tabs. + * @param boolean $backup If true, backup the file before patching. */ - public function patch_file( $file, $search, $replace, $retry_tabs = false ) { + public function patch_file( $file, $search, $replace, $retry_tabs = false, $backup = true ) { if ( $retry_tabs ) { $search = str_replace( "\t", ' ', $search ); $replace = str_replace( "\t", ' ', $replace ); @@ -459,7 +460,7 @@ public function patch_file( $file, $search, $replace, $retry_tabs = false ) { if ( !strstr( $content, $replace ) && strstr( $content, $search ) ) { // Backup file before patch with timestamp of patch yyyy_mm_dd_hh_mm - if ( !file_exists( $file . '.bak' ) ) { + if ( !file_exists( $file . '.bak' ) && $backup ) { copy( $file, $file . '.bak_' . date('Y_m_d_H_i') ); } $content = str_replace( $search, $replace, $content );