I think I may have just discovered a major issue with WordPress. It would seem that WordPress is loading two pages at a time, the second loading after the first one has rendered on the screen, the other somehow in the background.
Here’s what I did to discover it. I’m hoping someone else can verify this and make sure it’s not just my environment and that I’m not just plain crazy!
- Create a fresh, new WordPress 3.3.1 instance on MAMP.
- Turn on WordPress DEBUG logging in the wp-config.php file.
- Turn on the permalink structure for “month and name” (
http://localhost/fresh/2012/02/sample-post/
) - Create at least one extra page than the already generated Sample Page. I called mine “About Us.”
- Create a very simple plugin to track the $_SERVER[“REQUEST_URI”] call and send it to the log.
<?php /* Plugin Name: mytest */ add_action('init', 'mytest'); function mytest(){ if(!is_admin()) error_log($_SERVER["REQUEST_URI"]); } |
- Activate the plugin.
- Tail the log file (tail -f Sites/fresh/wp-content/debug.log) in Terminal.
- Visit your site and watch the log file. Visiting “Home” only causes the request to fire once, visiting the new About Us page only fires once. But, here’s the strange thing: visit the Sample Page and it fires both the Sample Page and the About Us page.
- Create more pages. Watch the logs.
- Wonder, “WHY??”
UPDATE: MAMP was the problem. Restarting Apache did the trick. I’m still not sure what caused it, but at least I know the root.