Make WordPress Core

Opened 15 years ago

Closed 15 years ago

#12255 closed defect (bug) (fixed)

apache_get_modules() not returning mod_rewrite status

Reported by: johnonolan's profile JohnONolan Owned by: ryan's profile ryan
Milestone: 3.0 Priority: normal
Severity: normal Version: 3.0
Component: Multisite Keywords:
Focuses: Cc:

Description

When testing "Network" activation on WP3.0a received a notification stating "Note It looks like mod_rewrite is not installed." - however mod_rewrite was both installed and active.

I've been told by Andrew Nacin from the WP Testers list that the reason for this could be that apache_get_modules() exists but isn't returning that mod_rewrite is there.

He also said "Based on the logic you had to go through to get that specific error, it simply sounds like PHP has no idea you have mod_rewrite and that our apache_mod_loaded() function (which we should to move the MS network upgrade over to) wouldn't think you have mod_rewrite either"

Relevant info:

PHP 5.2.12
Apache 2.2.14

var_dump( apache_mod_loaded('mod_rewrite') ); returns false, FWIW this also returns false on the same server but running 2.9.2

RewriteEngine On is present on line 1 of .htaccess

Change History (8)

#1 @erisds
15 years ago

  • Cc erisds added
  • Component changed from Multisite to Permalinks
  • Owner set to ryan

apache_mod_loaded does two tests to see if a module is loaded:

  1. if the method apache_get_modules is available it checks the list of returned modules
  2. if the method apache_get_modules is not available it checks the output of phpinfo().

However, on many shared hosting setups neither apache_get_modules is available nor are the details of available modules provided via the output of phpinfo().

This means that both tests fail, but the requested module may still be available.

A more reliable test is required to check if mod_rewrite is available during the "Network" activation, such as writing a test rewrite rule to the .htaccess and checking the returned URL.

#2 @nacin
15 years ago

  • Keywords multisite added

When you invoked phpinfo() in the testers thread, I assumed you checked there to see if mod_rewrite was enabled. Sorry about that.

If it isn't there, then there's not much we can do. We can make sure the error better indicates that mod_rewrite *may* still be enabled, but we just won't know. At the very least, the ticket can serve as a way for us to replace our manual apache_get_modules() check with apache_mod_loaded(), and provide more helpful messages.

On the other hand, if it was in phpinfo() but apache_get_modules() didn't verify it as a module, then that would have been a setup we hadn't accounted for (probably because it doesn't quite make sense based on how apache_get_modules() works). That's what I was concerned about.

#3 @sivel
15 years ago

  • Keywords multisite removed
  • Milestone 3.0 deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Closing as a duplicate of #11604

The same checks are used in single site as they are in multisite.

#4 @nacin
15 years ago

  • Component changed from Permalinks to Multisite
  • Milestone set to 3.0
  • Resolution duplicate deleted
  • Status changed from closed to reopened

It's actually a duplicate (well, it will be) of #11848, in that got_mod_rewrite() returns true as long as it's Apache and a filter doesn't have it return false.

The same checks aren't used, and that's what I'm going to leave this ticket open for. We use apache_get_modules() in network.php, but in WP we have apache_mod_loaded() and got_mod_rewrite(). We should transition over to these.

Since get_mod_rewrite() may return false positives (while apache_get_modules() by itself may return false negatives), it's more than just a simple function call switch, we'll have to massage the messages a bit.

This has a decent amount to do with wpfs so I'll add this to my to-do list.

#5 @nacin
15 years ago

I've implemented some logic in network.php that goes like this:

  1. Check for mod_rewrite using apache_mod_loaded(). If true, then mod_rewrite definitely exists and we continue.
  1. Otherwise, check for mod_rewrite using got_mod_rewrite(). If true, then we're running Apache and can assume mod_rewrite. If that's the case, we still display a notice.
  1. Otherwise, we must assume that mod_rewrite does not exist, and we display a warning.

See http://core.trac.wordpress.org/browser/trunk/wp-admin/network.php?rev=13632#L71.

#6 @johnonolan
15 years ago

Hi Nacin,
Just tested this with the latest nightly build and I still get the same error message

"Note It looks like mod_rewrite is not installed."

#7 @automattor
15 years ago

(In [13782]) Some improvements to the network.php mod_rewrite checks. see #12255

#8 @nacin
15 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

On update to trunk, John confirmed for me he was seeing the more helpful messages, which play off the assumptions (or lack thereof) that apache_mod_loaded() and got_mod_rewrite() make.

Closing as fixed, thanks for your help.

Note: See TracTickets for help on using tickets.