WordPress.org

Forums

[resolved] Fatal error: Cannot redeclare cforms_activate() (17 posts)

  1. Chintaru
    Member
    Posted 6 years ago #

    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/

  2. Jeff
    Member
    Posted 6 years ago #

    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?

  3. Chintaru
    Member
    Posted 6 years ago #

    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?

  4. olivers
    Member
    Posted 6 years ago #

    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.

  5. Jeff
    Member
    Posted 6 years ago #

    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?

  6. Chintaru
    Member
    Posted 6 years ago #

    @olivers; thank you for your reply :) The code's exactly the same.

  7. olivers
    Member
    Posted 6 years ago #

    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...

  8. Chintaru
    Member
    Posted 6 years ago #

    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.

  9. Chintaru
    Member
    Posted 6 years ago #

    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 ...

  10. olivers
    Member
    Posted 6 years ago #

    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?

  11. olivers
    Member
    Posted 6 years ago #

    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 »

  12. Chintaru
    Member
    Posted 6 years ago #

    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... :(

  13. olivers
    Member
    Posted 6 years ago #

    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?

  14. Chintaru
    Member
    Posted 6 years ago #

    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.

  15. olivers
    Member
    Posted 6 years ago #

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

  16. Jeff
    Member
    Posted 6 years ago #

    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.

  17. rmoore01
    Member
    Posted 5 years ago #

    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 had a similar error when upgrading to version 10.5.1 & 10.5.2 of cforms.
    If like me you did not read the upgrade notes dooh!!! and just tried uploading the zip file in the plugins admin then it will create a folder in the route of your plugins called Patch 10.5.1 which has a cforms php file. So 2 files exist and cforms will not activate. Delete this Patch folder and ftp all the upgrade files into your original cforms folder.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags