FIX: Simplify sed command in add_disable_wpcron_to_config
Problem: Complex quoting in sed command caused 'extra characters after command' error Solution: Use @ delimiter instead of # and simplify variable substitution The issue was multi-level quote escaping that didn't work correctly. Changed to simpler sed syntax with @ delimiter which handles special chars better. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1585,16 +1585,16 @@ remove_disable_wpcron_from_config() {
|
||||
# Returns 0 on success, 1 on failure
|
||||
add_disable_wpcron_to_config() {
|
||||
local wp_config="$1"
|
||||
local new_define="define('$WP_CRON_DISABLED_VAR', true);"
|
||||
|
||||
# Try to insert before WordPress stop editing comment (proper convention)
|
||||
if grep -q "$WP_CONFIG_MARKER" "$wp_config" 2>/dev/null; then
|
||||
sed -i '#'"$WP_CONFIG_MARKER"'#i\
|
||||
define('"'"''"$WP_CRON_DISABLED_VAR"''"'"', true);' "$wp_config"
|
||||
# Use sed with @ delimiter to avoid escaping issues, insert before marker
|
||||
sed -i.wpbak "@$WP_CONFIG_MARKER@i\\$new_define" "$wp_config"
|
||||
return 0
|
||||
elif grep -q "$WP_EDIT_START" "$wp_config"; then
|
||||
# Fallback: if no stop editing found, add after opening PHP tag
|
||||
sed -i '#'"$WP_EDIT_START"'#a\
|
||||
define('"'"''"$WP_CRON_DISABLED_VAR"''"'"', true);' "$wp_config"
|
||||
sed -i.wpbak "@$WP_EDIT_START@a\\$new_define" "$wp_config"
|
||||
return 0
|
||||
else
|
||||
# File format is unexpected
|
||||
|
||||
Reference in New Issue
Block a user