Make WordPress Core

Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#13581 closed defect (bug) (worksforme)

Plugin Initialization fails in PHP 4 (WP 3.0-Beta 2) - initializes fine under PHP 5 or PHP 4 (WP 2.9.2)

Reported by: bennebw's profile bennebw Owned by: westi's profile westi
Milestone: Priority: normal
Severity: normal Version: 3.0
Component: Plugins Keywords: reporter-feedback
Focuses: Cc:

Description

Was testing PhotoSmash plugin under WP 3.0 Beta 2 and found that it does not install (will attach the init file if possible) under PHP4. The plugin install file creates database tables and sets ReWrite up.

The fact that it installs fine with PHP 4 and WP 2.9.2 or with PHP 5 and WP 3.0 Beta-2 would indicate that WP 3.0 is breaking PHP 4 compatibility somewhere as the only thing that has changed in my test is the WP version.

I am using a 1and1.com shared Linux host. The PHP 4 version is PHP 4.4.9 (I think).

The result of Activating the plugin under PHP 4 and WP 3.0 Beta 2 is that it produces a Error 500 Server error. The plugin does activate, but no database tables are created. Please see attached file for the details

Attachments (1)

bwbps-init.phpXXX (18.6 KB) - added by bennebw 15 years ago.
PhotoSmash Initialization filed

Download all attachments as: .zip

Change History (16)

@bennebw
15 years ago

PhotoSmash Initialization filed

#1 @westi
15 years ago

  • Keywords reporter-feedback added
  • Milestone changed from Unassigned to 3.0

What error message do you see in the error log?

#2 @ryan
15 years ago

WP 3.0 has stricter checks for plugins that create warnings when they activate. It could be the plugin has the same problems in WP 2.9.2 but slips through 2.9.2's weaker checks.

#3 @ryan
15 years ago

Undefined variable:  wpdb in /Applications/MAMP/htdocs/trunk/wp-content/plugins/photosmash-galleries/bwb-photosmash.php on line 46

Undefined $wpdb occurs all over the place.

#4 follow-up: @ryan
15 years ago

Plugins can't assume they are running from global scope. That plugin needs to declare $wpdb as global.

#5 @ryan
15 years ago

If that's the plugin you mean, I'm not sure how it would install under any recent version of WP. I think you haven't been able to assume activating within global scope for awhile.

#6 in reply to: ↑ 4 ; follow-up: @bennebw
15 years ago

Replying to ryan:

Plugins can't assume they are running from global scope. That plugin needs to declare $wpdb as global.

Just for kicks, I tried to Install NextGen Gallery under PHP 4, WP 3.0 Beta-2. Same problem. I'll be honest, that makes me feel a wee bit better that it's not limited to my plugin, because I spent several hours trying to debug it last night, but couldn't figure it out without know what might have changed in WP 3 that might be causing the issue.

$wpdb is declared global on line 22. As I mentioned, it loads fine in PHP 5 under WP 3.0, but PHP 4 is having real problems.

Here's the code that gets processed in PhotoSmash up to the point the $wpdb is declared global:

Starting in the main plugin file, the add_action to trigger the initialization class:

Call the INIT function whenever the Plugin is activated
add_action('activate_photosmash-galleries/bwb-photosmash.php',
array(&$bwbPS, 'init'));

Now the function that gets run in the $bwbPS object to load the Initialization class:

Called when plugin is activated

function init(){


require_once(WP_PLUGIN_DIR . "/photosmash-galleries/admin/bwbps-init.php");
$bwbpsinit = new BWBPS_Init();

}

Now the start of the Initialization Class:

Code for initializing BWB-PhotoSmash plugin when it is activated in Wordpress Plugins admin page
class BWBPS_Init{

var $adminOptionsName = "BWBPhotosmashAdminOptions";


Constructor
function BWBPS_Init(){

Create the PhotoSmash Tables if not exists


$psOptions = get_option($this->adminOptionsName);


$label = $psOptionstag_label? ? esc_attr($psOptionstag_label?) : "Photo tags";

$slug = $psOptionstag_slug? ? $psOptionstag_slug? : "photo-tag";


register_taxonomy( 'photosmash', 'post', array( 'hierarchical' => false, 'label' => ($label, 'series'), 'query_var' => 'bwbps_wp_tag', 'rewrite' => array( 'slug' => $slug ) ) );


global $wp_rewrite;

$wp_rewrite->flush_rules();


global $wpdb;


require_once(ABSPATH . 'wp-admin/includes/upgrade.php');

#7 in reply to: ↑ 6 @bennebw
15 years ago

Sorry the code is all screwed up I posted above. I haven't participated in this process before, so please excuse any faux pas'.

#8 follow-up: @nacin
15 years ago

Can you try again using the latest nightly?

#9 in reply to: ↑ 8 @bennebw
15 years ago

Replying to nacin:

Can you try again using the latest nightly?

I uploaded the Nightly Build (all except wp-content and wp-config.php). It upgraded the database to the new build.

I tried installing PhotoSmash Galleries and NextGen Gallery on PHP 4 and received the "Error 500 - Internal Server..." error message again.

Both plugins installed fine under PHP 5.

Looks like it's still broken...if I did everything correctly.

#10 @markjaquith
15 years ago

I am able to activate both PhotoSmash and NextGEN Gallery on WP 3.0-RC1 while running PHP 4. No problems.

#11 follow-up: @markjaquith
15 years ago

  • Milestone changed from 3.0 to Unassigned
  • Resolution set to worksforme
  • Status changed from new to closed

It seems to be a problem with 1and1. Lots of reports that many plugins fail to activate on 1and1 with PHP4, or that WordPress auto update fails to work. Suggested solution is to switch to PHP5 or find a new host.

e.g. http://www.gp2b.com/error-500-–-internal-server-error-in-wordpress-with-11/

#12 in reply to: ↑ 11 @bennebw
15 years ago

Replying to markjaquith:

It seems to be a problem with 1and1. Lots of reports that many plugins fail to activate on 1and1 with PHP4, or that WordPress auto update fails to work. Suggested solution is to switch to PHP5 or find a new host.

e.g. http://www.gp2b.com/error-500-–-internal-server-error-in-wordpress-with-11/

Ryan appears to have had problems installing under PHP 4 using MAMP (not 1and1). That would suggest that 2 out of 3 setups had problems under PHP 4. Perhaps the decision to ignore this is a subtle shove in the back of the PHP4 laggards? No arguments from me as long as this is the intent.

The gp2b.com article referenced above calls out plugins that are PHP 5 only, which neither NextGen nor PhotoSmash stipulate as a requirement.

#13 follow-up: @nacin
15 years ago

  • Milestone Unassigned deleted

bennebw: ryan was seeing something different, see also #13585. He was able to activate the plugin (with the less-strict checks in place). It's specifically a 1and1 issue best we can tell otherwise.

#14 in reply to: ↑ 13 @bennebw
15 years ago

Replying to nacin:

bennebw: ryan was seeing something different, see also #13585. He was able to activate the plugin (with the less-strict checks in place). It's specifically a 1and1 issue best we can tell otherwise.

Thanks for the clarification.

#15 @bennebw
15 years ago

Confirming the consensus, NextGen and PhotoSmash both install fine under PHP 4 on my MediaTemple account. Appears to be specific to 1and1.

Note: See TracTickets for help on using tickets.