WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Fatal error: Cannot redeclare cforms_activate()

[Resolved] Fatal error: Cannot redeclare cforms_activate()

  • I just sucessfully updated from WP 2.6.2 to WP 2.7 and wanted to install cforms. But, whenever I try to activate it, I get this error message:

    Fatal error: Cannot redeclare cforms_activate() (previously declared in /home/public_html/wp-content/plugins/cforms/cforms.php:59) in /home/public_html/wp-content/plugins/cforms/cforms.php on line 61

    Is this a plugin compatibility issue?

    http://wordpress.org/extend/plugins/cforms/

Viewing 15 replies - 1 through 15 (of 16 total)
  • Jeff

    @upekshapriya

    I get the same error after moving my WordPress 2.7 installation to a new host. (I copied and replaced all instances of the host name as well as the path name in the SQL. Everything else works perfectly fine.) cforms is version 9.4.

    The first problem though was the message:

    “It appears that WP has corrupted your cforms settings, the settings array can not be read properly.” when I go to the cforms settings page.

    It shows me the array from the options table and says it will try and fix it, which it appears to do so, then asks me to deactivate and reactivate cforms. At this stage I get the above fatal error.

    Any solutions anyone? Is it a bug in cforms?

    I just tested if any plugins could be the problem. But even without any other plugin, the error still occurs 🙁

    I also tried to replace my WP 2.7 installation with a fresh one, but to no avail. Any help please?

    this is the first time I’m hearing about this, and then two times in a row…jeez.

    not sure why this comes up, these are the orig lines, can you confirm?:

    register_activation_hook( __FILE__, 'cforms_activate' );
    function cforms_activate() {
    	cforms_init();
    	require_once(dirname(__FILE__) . '/lib_activate.php');
    }

    @upekshapriya

    did you also manipulate the cforms setting in SQL? If so, not a good idea, this will very likely break cforms.

    cforms can adjust (the vital settings) to new hosts simply by deactivating and reactivating.

    Jeff

    @upekshapriya

    Before importing the SQL into phpMyadmin on the new server I opened the gz file and extracted the text file. Then I did a search and replace in Notepad++ to change all references to the old host url to the new host url, then I also did a search and replace on the absolute path to the files on the server /home/etc/etc/htdocs/… Then I re gzipped it and imported it in phpMyadmin.

    Is all that a problem for cforms?

    @olivers; thank you for your reply 🙂 The code’s exactly the same.

    do you have another copy/version of cforms in your plugins folder?
    I can’t think of a reason why WP would try to load cforms.php twice and thus cause the redeclare conflict…

    Nope, I deleted all other folders in the /plugins/ directory except a fresh cforms folder. Still gave the error, strangely enough.

    Edit: I just installed a 100% new WordPress installation and installed cforms without any errors. I went to the existing WP installation, removed everything related to cforms in the database, removed all files except wp-config.php and copied the files from the new installation to the existing one. Still didn’t solve it! I guess it has to be a database thing after all…

    Edit2: after a little investigating, it appears wp_options is the troublemaker. I’ll go dig a little deeper to see if I can find a more specific problem.

    Found something: db_version in the wp_options table is what caused the trouble. I deleted the row, hit refresh on the WP-admin page, hit the upgrade button on the automatically redirected upgrade.php page (errors can be ignored) and deactivated cforms and activated it again without any problems.

    BUT: there is no button to cforms on the adminpanel :’)

    Edit: …And when I manually navigate to the cforms options page, I get the same error. ARGH!

    Edit2: Okay, well… The only solution for now is to delete the wp_options table in the database, and run wp-admin/upgrade.php …

    Still odd. I can’t see the connection between the ‘db_version’ record and the err displayed.
    My wp_options show:
    db_version = 9872

    and it works just fine. To my knowledge, the err is a result of the cforms.php file being loaded twice, hence the ‘redeclare’ err.

    EDIT: what’s your PHP MEM setting?

    Found the solution, which goes into the next release.

    Quick fix:

    Edit cforms.php and replace this line [close to the top line~57]
    register_activation_hook( __FILE__, 'cforms_activate' );
    with this:
    register_activation_hook( basename(__FILE__), 'cforms_activate' );


    Please also visit the cforms forum »

    It fixed the activation error, but the button won’t show up on the admin page. And when I manually navigate to it, I get the error once again… 🙁

    the same error (redeclare..) ?
    do you have a non standard WP setup (wp-content / plugin folders) ?

    do you possibly still have an old (corrupt) cforms_settings entry in wp_options?

    did you deactivate and reactivate the plugin?

    Yep,

    Fatal error: Cannot redeclare cforms_activate() (previously declared in /home/public_html/wp-content/plugins/cforms/cforms.php:59) in /home/public_html/wp-content/plugins/cforms/cforms.php on line 61

    I never installed cforms before… I guess it has to do with the upgrade from WP 2.6.2 (or maybe older updates left a trace) to 2.7, since it works fine on a clean install and with wp_options reset.

    ok, thanks. so i think this topic is then resolved.

    Jeff

    @upekshapriya

    Thanks very much for sorting it out so simply. I look forward to the update.

    It stopped that error but I still had a problem with the corrupted data so I went into phpMyAdmin and copied the cforms entry from the wp_options table from the old site to the new site and it all now works perfectly.

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘[Resolved] Fatal error: Cannot redeclare cforms_activate()’ is closed to new replies.