Ticket #3002 (closed defect: fixed)

Opened 2 years ago

Last modified 1 year ago

On Windows machines register_activation_hook() does not work if plugin is in a subfolder of the plugins dir

Reported by: McShelby Assigned to: westi
Priority: normal Milestone: 2.2.3
Component: Administration Version: 2.0.4
Severity: major Keywords: has-patch plugin_basename register_activation_hook commit
Cc:

Description

If you try to create a plugin in a subfolder of the 'plugins' directory and your are running Wordpress on a Windows machine, the function registered by register_activation_hook() will not be executed.

This is because of different backslashes on UNIX and Windows and the way the function plugin_basename()/admin panel works.

On Windows plugin_basename() returns the backslash in its return value while on Unix returning the slash. The plugins activation screen in the admin panel of Wordpress is always using slashes. You can easily see this by hovering over Askimets activate/deactivate button.

register_activation_hook() is using plugin_basename() to install the activation filter while the file wp-admin/plugins.php will use the value from the plugins activation screen to access the installed filter. Because of different slash types, the filter will not be found and so will never be executed.

If you take a look into the Bad Behaviour 2.0.4 plugin, you'll see from the comments that other guys have had the same problem with register_activation_hook().

Attachments

3002.plugin_basename.diff (0.7 kB) - added by DD32 on 06/26/07 04:08:13.
plugin_basename fix from #4408

Change History

08/06/06 12:51:02 changed by McShelby

  • milestone set to 2.1.

08/06/06 12:52:09 changed by McShelby

  • version set to 2.0.4.

08/09/06 19:13:42 changed by ryan

We can convert everything to slashes when registering the hook.

08/10/06 21:05:47 changed by McShelby

From my point of view I am not sure which one to fix: plugin_basename(), the codepart in plugins.php or the code location where the activate/deactivate links for the plugin admin panel are generated.

I fear that different slash types may cause problems in other parts of WP too.

I think it's not the best idea to fix the slash during registration of the hook. I would prefer having the correct slash in the link of the activate/deactivate button.

11/30/06 22:19:34 changed by matt

  • milestone changed from 2.1 to 2.2.

12/14/06 20:55:26 changed by McShelby

Why is there no interest in fixing this hook with the next *gasp* "major" version of WP?

12/14/06 21:36:00 changed by Nazgul

  • keywords set to needs-patch.

The release of 2.1 is nearby, therefore people don't want to change anything "major" anymore for that release, but just get it stable and out of the door.

The 2.2 version will have a much shorter release time than 2.1 has had. It's expected to be around 4-6 months after the 2.1 release, so pushing this back to 2.2 doesn't mean you'll have to wait very long for it to be incorporated.

Also providing patches helps getting things in faster. We can't fix anything without somebody creating a patch.

03/27/07 18:50:14 changed by foolswisdom

  • milestone changed from 2.2 to 2.4.

06/05/07 08:41:39 changed by westi

Patch avail on #4408

06/05/07 14:41:17 changed by foolswisdom

  • milestone changed from 2.4 (future) to 2.3 (trunk).

06/26/07 04:08:13 changed by DD32

  • attachment 3002.plugin_basename.diff added.

plugin_basename fix from #4408

06/26/07 04:09:04 changed by DD32

  • keywords changed from needs-patch to has-patch plugin_basename register_activation_hook.

07/22/07 20:54:47 changed by westi

  • owner changed from anonymous to westi.
  • status changed from new to assigned.

08/23/07 13:57:41 changed by westi

  • keywords changed from has-patch plugin_basename register_activation_hook to has-patch plugin_basename register_activation_hook commit.

08/23/07 16:07:29 changed by westi

  • status changed from assigned to closed.
  • resolution set to fixed.

(In [5924]) Fix plugin basename for Windows servers. Fixes #3002 props Ozh

08/23/07 16:52:36 changed by westi

  • status changed from closed to reopened.
  • resolution deleted.
  • milestone changed from 2.3 (trunk) to 2.2.3.

re-open for backport to 2.2.3

08/23/07 18:11:44 changed by westi

  • status changed from reopened to closed.
  • resolution set to fixed.

(In [5928]) Fix plugin basename for Windows servers. Fixes #3002 for 2.2.x props Ozh