#!/bin/bash # Includes . $(miniade) || { echo "${0##*/}: ERROR: miniade failed (hint: run 'miniade' to see error)" >&2; exit 1; } # Configurable stuff # Other globals MODROOT=$(cd $(dirname $(realpath $0))/.. && pwd) main() { local MY_ARGS # Defaults for options MODE=check # Process options special_opts_handler() { case $1 in --explain) MODE=explain ;; *) return 1 ;; esac } miniade_process_options --special-opts-handler=special_opts_handler --help-handler=help MY_ARGS "$@" && set -- "${MY_ARGS[@]}" # Process arguments # (delegated) # Sanity checks and derivations # (delegated) # Guts (delegate) mode_$MODE "$@" } help() { local PROGNAME miniade_get_progname PROGNAME echo "Usage: $PROGNAME [ ] { ... | --explain }" exit 0 } mode_check() { local PROGNAME # Sanity checks and derivations miniade_get_progname PROGNAME # Process arguments [ $# -ge 1 ] || miniade_bad_usage PHP_FILES=( "$@" ) # Guts for PHP_FILE in "${PHP_FILES[@]}"; do SITE_NAME=$(realpath $PHP_FILE | sed -r 's@.*www/(.*)/wp-admin/.*@\1@') miniade_debug 10 "main: $SITE_NAME: checking ..." if grep -q "start of workaround for #36201" "$PHP_FILE"; then miniade_info "$SITE_NAME: already patched" elif cmp -s $PHP_FILE $MODROOT/share/$PROGNAME/class-wp-list-table.php.20240403093400.pristine; then miniade_info "$SITE_NAME: applying '20240403093400' patch ..." cp $MODROOT/share/$PROGNAME/class-wp-list-table.php.20240403093400.patched $PHP_FILE elif cmp -s $PHP_FILE $MODROOT/share/$PROGNAME/class-wp-list-table.php.20240717082023.pristine; then miniade_info "$SITE_NAME: applying '20240717082023' patch ..." cp $MODROOT/share/$PROGNAME/class-wp-list-table.php.20240717082023.patched $PHP_FILE else miniade_warning "$SITE_NAME: needs patching" fi done } mode_explain() { # Process arguments [ $# = 0 ] || miniade_bad_usage # Guts cat <<'EOF' 1) Edit the affected files. 2) In each, locate the *two* occurrences of this line: $current_url = set_url_scheme(...); 3) *Immediately after* each occurence add this code (which is suitable indented): /* start of workaround for #36201 */ if(!empty($_SERVER['HTTP_X_FORWARDED_HOST'])){ $hostname = $_SERVER['HTTP_X_FORWARDED_HOST']; } else { $hostname = $_SERVER['HTTP_HOST']; } $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $hostname . $_SERVER['REQUEST_URI']; /* end of workaround for #36201 */ 4) For more details see https://core.trac.wordpress.org/ticket/36201. EOF } main "$@"