Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite rules are not flushed on activation #10

Open
jasalt opened this issue Jul 1, 2023 · 4 comments
Open

Rewrite rules are not flushed on activation #10

jasalt opened this issue Jul 1, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@jasalt
Copy link

jasalt commented Jul 1, 2023

Thought to try this out on a minimal client WP ajax-widget project and partially out of personal interest in django+htmx development. I didn't get it to run after half a day trying to run the demo however.

Testing log

I set up the suggested wp-env development environment on Debian stable (NodeJS v18.13.0, Docker version 24.0.2 rootless). wp-env start gets the stock WP installation up and running with htmxpress-plugin activated ok and not producing errors. Htmx javascript file loads globally on site (from unpkg.com).

When accessing demo urls I only get the classic Apache "Not Found" 404 page, access log:

"GET /htmxpress HTTP/1.1" 404 489 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/114.0"
"GET /htmx/ascii HTTP/1.1" 404 490 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/114.0"
"GET /html/partial-ascii HTTP/1.1" 404 490 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/114.0"
"GET /htmx/demo HTTP/1.1" 404 490 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/114.0"

Same results on Mac M1, Docker Desktop 4.19.0.

"GET /htmx/demo HTTP/1.1" 404 490 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/114.0"

Another trial with Linux laptop and using VVV vagrant box which is personally more familiar tool. Installing htmxpress plugin as zip on the default "wordpress-one" site. Htmx script loads ok here as well. Accessing https://one.wordpress.test/htmx redirects to same url with ending slash and just shows the stock WP home page.

Access log:

192.168.56.1 - - [01/Jul/2023:14:21:26 +0000] "GET /htmx HTTP/1.1" 301 5 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/114.0"
192.168.56.1 - - [01/Jul/2023:14:21:26 +0000] "GET /htmx/ HTTP/1.1" 200 13372 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/114.0"
192.168.56.1 - - [01/Jul/2023:14:33:58 +0000] "GET /htmx/ascii HTTP/1.1" 301 5 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/114.0"
192.168.56.1 - - [01/Jul/2023:14:33:59 +0000] "GET /htmx/ascii/ HTTP/1.1" 200 13372 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/114.0"
192.168.56.1 - - [01/Jul/2023:14:38:24 +0000] "GET /htmx/partial-ascii HTTP/1.1" 301 5 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/114.0"
192.168.56.1 - - [01/Jul/2023:14:38:25 +0000] "GET /htmx/partial-ascii/ HTTP/1.1" 200 13372 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/114.0"
192.168.56.1 - - [01/Jul/2023:14:38:50 +0000] "GET /htmx/demo HTTP/1.1" 301 5 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/114.0"
192.168.56.1 - - [01/Jul/2023:14:38:51 +0000] "GET /htmx/demo/ HTTP/1.1" 200 13372 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/114.0"

Spent bit of time reading WP Rewrite Endpoints API docs and related code but didn't get any further yet...

@svandragt
Copy link
Owner

Hi sorry for the bad first impression. I noticed that wp env did not properly run the flush rewrite rules (part of the plug-in activation) for me, but haven’t looked more into it. As a result the endpoints aren’t activated. This is what you’re seeing.

Anyway if you go to Settings > Permalinks and press save it will flush them and everything will start working for you.
Alternatively if the bug is not in the plug-in then deactivating and deactivating the plug-in should also work.

Let me know if I can help and apologies for the first run experience.

@svandragt svandragt changed the title Problems getting demo to run Rewrite rules are not flushed on activation Jul 2, 2023
@svandragt svandragt added the bug Something isn't working label Jul 2, 2023
@jasalt
Copy link
Author

jasalt commented Jul 3, 2023

Thank's, I got the demo working. Seems that plugin has trouble writing redirects with the default "Plain" permalink setting. Changed it to "Post type" and plugin started working. Seen this setting being a requirement in some plugins earlier.

Default TwentyTwentyThree block theme gives Deprecated: File Theme without header.php is deprecated since version 3.0.0 with no alternative available. but all the demo functionality works now as in video. Deprecation warning disappears with the Susty theme activated.

EDIT: tested on Mac with wp-env, but changing permalink setting does not seem to work on Debian with wp-env (rootless docker). The registered endpoint now shows up with wp rewrite list command but /htmx/ still gives 404 instead of the greeting and wp rewrite flush does not help. Works on Debian with VVV though.

On a side note, while trying to get it working with "Plain" permalink setting, there was some weird effects and differences between wp-env and VVV. While redirect path was not getting registered, I was able to get the demo page open from /?htmx=demo url. On wp-env I would only get 404 responses back to htmx doing queries from Serverside rendering partial and Live search tests. On VVV the Serverside rendering partial test gets the WP homepage HTML as response (not the ascii partial) and replaces the button with it. Live search seemed to work though while it didn't with wp-env. I was using it all the wrong way but though to make a note about it.

@jasalt
Copy link
Author

jasalt commented Oct 1, 2024

Similar issue noted in another plugin doing same sort of thing EstebanForge/HTMX-API-WP#9.

@svandragt
Copy link
Owner

Cheers I’ll have another look

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants