Skip to content

Auto-set permalink structure during setup if plain/default detected#13

Open
coleplx wants to merge 6 commits intoWordPress:trunkfrom
coleplx:trunk
Open

Auto-set permalink structure during setup if plain/default detected#13
coleplx wants to merge 6 commits intoWordPress:trunkfrom
coleplx:trunk

Conversation

@coleplx
Copy link
Copy Markdown

@coleplx coleplx commented Apr 30, 2026

Also, on line 895, added || true to prevent the script from failing and exiting silently when wp config get SAVEQUERIES returns false.

Motivation:
The script kept failing on single-idle due to permalinks being disabled. The requested path returned WordPress' default 404 HTML. 😞

@coleplx coleplx marked this pull request as draft May 1, 2026 15:14
@coleplx coleplx marked this pull request as ready for review May 1, 2026 15:45
@desrosj desrosj requested a review from Copilot May 5, 2026 01:35
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the setup flow in rtc-test.sh to reduce failures caused by WordPress installs using “Plain” permalinks and to prevent set -e from aborting setup when SAVEQUERIES is not defined in wp-config.php.

Changes:

  • Auto-detect “Plain/default” permalink structure and attempt to switch to /%postname%/ during WP-CLI setup.
  • Prevent wp config get SAVEQUERIES from aborting the script when the constant is unset by appending || true.
  • Update manual setup instructions to include enabling pretty permalinks and renumber the steps.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread rtc-test.sh Outdated
Comment thread rtc-test.sh Outdated
Comment thread rtc-test.sh Outdated
coleplx and others added 3 commits May 5, 2026 12:00
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 7 comments.

Comment thread rtc-test.sh
Comment on lines +840 to +857
if [ -n "${site_url}" ] && curl -fsS -o /dev/null "${rest_url}" >/dev/null 2>&1; then
printf 'Permalinks: set to /%%postname%%/\n'
# Re-check the REST API after changing permalinks. Updating the option
# alone is not enough if server rewrite rules are still misconfigured.
site_url="$(wp "${WP_FLAGS[@]}" option get siteurl 2>/dev/null)" || site_url=""
rest_probe_url="${site_url%/}/wp-json/"
rest_probe_code="$(curl -sS -L -o /dev/null -w '%{http_code}' "${rest_probe_url}" 2>/dev/null)" || rest_probe_code=""
case "${rest_probe_code}" in
2*)
printf 'REST API: %s (OK after permalink update)\n' "${rest_probe_url}"
;;
*)
die "Permalinks were updated, but ${rest_probe_url} is still unreachable (HTTP ${rest_probe_code:-request failed}). Check web server rewrite rules and try again."
;;
esac
else
die "Could not make REST API reachable after setting permalink structure. Check permalinks/web server config and verify ${rest_url:-/wp-json/}."
fi
Comment thread rtc-test.sh
case "${rest_probe_code}" in
2*)
printf 'REST API: %s (OK after permalink update)\n' "${rest_probe_url}"
;;
Comment thread rtc-test.sh
Comment on lines +840 to +846
if [ -n "${site_url}" ] && curl -fsS -o /dev/null "${rest_url}" >/dev/null 2>&1; then
printf 'Permalinks: set to /%%postname%%/\n'
# Re-check the REST API after changing permalinks. Updating the option
# alone is not enough if server rewrite rules are still misconfigured.
site_url="$(wp "${WP_FLAGS[@]}" option get siteurl 2>/dev/null)" || site_url=""
rest_probe_url="${site_url%/}/wp-json/"
rest_probe_code="$(curl -sS -L -o /dev/null -w '%{http_code}' "${rest_probe_url}" 2>/dev/null)" || rest_probe_code=""
Comment thread rtc-test.sh
Comment on lines +838 to +840
site_url="$(wp "${WP_FLAGS[@]}" option get siteurl 2>/dev/null)" || site_url=""
rest_url="${site_url%/}/wp-json/"
if [ -n "${site_url}" ] && curl -fsS -o /dev/null "${rest_url}" >/dev/null 2>&1; then
Comment thread rtc-test.sh
Comment on lines +835 to +837
wp "${WP_FLAGS[@]}" rewrite flush >/dev/null 2>&1 \
|| die "Could not flush rewrite rules after setting permalink structure."
fi
Comment thread rtc-test.sh
Comment on lines +827 to +833
local site_url rest_probe_url rest_probe_code
printf 'Permalinks: default (query-string) -- setting to /%%postname%%/\n'
if wp "${WP_FLAGS[@]}" rewrite structure '/%postname%/' --hard >/dev/null 2>&1; then
:
else
printf 'Permalinks: hard rewrite failed; retrying without --hard\n'
wp "${WP_FLAGS[@]}" rewrite structure '/%postname%/' >/dev/null 2>&1 \
Comment thread rtc-test.sh
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants