Make WordPress Core

Opened 15 years ago

Closed 14 years ago

#12022 closed defect (bug) (duplicate)

wp-activate.php - Plugin + Activation bug

Reported by: wpmuguru's profile wpmuguru Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Multisite Keywords:
Focuses: Cc:

Description

MU Trac Ticket: http://trac.mu.wordpress.org/ticket/1151

I've seen a few of the other threads about wp-activate.php not working. I want to sorta put more detail. Originally I thought that the wp-activate.php page wasn't pulling in the functions.php cause I noticed that the page stopped loading at a specific point that required a custom function from my functions.php file. But after looking at the half loaded page I could see that it was pulling the load file which calls functions.php, it however is not pulling any dependencies from installed plug-ins, I also checked my php logs and saw that it was trying to pull a non-existent class that is available at all other times.

By default wp-activate.php page includes both the header.php and the footer.php. I found that if you have any functions being executed in the header that require a plug-in be activate, the page will fail and registration will not go through. Resulting in the half loaded page that many other people have gotten.

So as a test, I did:

functions.php

function foo () { echo 'bar'; };
function a() { // load some function that's dependent on a plug-in }

When I ran all these functions in the header.php the results were this:

  1. foo(); - success
  2. a(); - fail
  3. gravity_form(1); - fail

gravity_form() is a function available w/ the gravity forms plug-in put directly into the header.php, and was not located in my functions.php.

As a temporary stopgap I had to do:

if ( basename($_SERVER['PHP_SELF']) != 'wp-activate.php' ) include('foo.php');

which keeps the section that had previously had my functions in it from loading if it's trying to activate.

Anyway, I hope this helps someone figure out how to actually fix this issue.

also posted in the forum: http://mu.wordpress.org/forums/topic/15324

Change History (12)

#1 @wpmuguru
15 years ago

  • Keywords needs-feedback added

The plugin commander plugin can be used to auto activate plugins on new blogs.

There are also activation hooks that can be used during the activation process. Based on the description, it looks to me like the code is being executed directly in the plugin instead of via a hook.

#2 @wpmuguru
15 years ago

  • Resolution set to invalid
  • Status changed from new to closed

Try

if( function_exists('gravity_form') ) { 
    gravity_form(1);
}

That's been fairly standard programming practice for WP since I've been working with it. If it's not a core function or a function form this theme/plugin, check to make sure it exists before calling it.

#3 @nacin
15 years ago

  • Milestone Unassigned deleted

#4 @eddiemoya
14 years ago

This is still a problem. Stopping the error is not so much the issue as getting functions used in the theme that are defined in plugins to work when wp-activate.php loads.

Removing define("WP_INSTALLING", true); will do that. However I will have to test the impact on the activation process itself.

#6 @eddiemoya
14 years ago

  • Cc eddiemoya added

#7 @ryan
14 years ago

  • Milestone set to 3.1
  • Resolution invalid deleted
  • Status changed from closed to reopened

Opening per discussion on #12140.

#8 @c4mden
14 years ago

I've run across this bug as well, particularly when trying to hook into wpmu_activate_user. We collect extra fields from users when they sign up. This data goes into the meta field of the wp_signups table, and I move it over to the wp_usermeta table when a user activates their account.

I have to comment out the WP_INSTALLING line at the top of the wp-activate.php file. We don't let users create blogs, so I imagine we're safe. That line turns off all plugins altogether, and no filters will run. It seems to me that the wpmu_activate_user hook is completely worthless (as are any others on that page) unless that top line is commented out.

#9 @sboisvert
14 years ago

I'm not sure if this is a bug as much as that me (and the others in this thread) expect (and would want) different behavior on wp-activate. mainly to be able to use plugins for the hooks. Removing
define( "WP_INSTALLING", true );
would make this possible.
Now there is a partial fix coming in 3.1 (http://core.trac.wordpress.org/ticket/14718) that brings back the 2.9 behavior of being able to use network plugins as well as mu-plugins.

I don't know enough about the core to know what the implications of allowing all plugins to run on wp-activate.php but I would like to have that possibility.

#10 @sboisvert
14 years ago

  • Cc sboisvert added

#11 follow-up: @nacin
14 years ago

  • Keywords reporter-feedback close added; needs-feedback removed
  • Milestone changed from Awaiting Triage to Awaiting Review

Can this safely be closed as a duplicate of #14718? It's not the WP_INSTALLING, it's the re-ordering of code in wp-settings.php that causes network plugins to not be loaded.

#12 in reply to: ↑ 11 @ocean90
14 years ago

  • Keywords reporter-feedback close removed
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from reopened to closed

Replying to nacin:

Can this safely be closed as a duplicate of #14718? It's not the WP_INSTALLING, it's the re-ordering of code in wp-settings.php that causes network plugins to not be loaded.

Tested and the answer is yes.

#14718

Note: See TracTickets for help on using tickets.