WordPress.org

Ready to get started?Download WordPress

Forums

Campaign Monitor Ajax Forms
[resolved] When trying to activate - fatal error (11 posts)

  1. indigoclothing
    Member
    Posted 3 years ago #

    Fatal error: Cannot redeclare class services_json in /home/indigo/public_html/blog/wp-content/plugins/ajax-campaign-monitor-forms/createsend-php/class/services_json.php on line 114

  2. timvanoostrom
    Member
    Posted 3 years ago #

    Comment out line 3 in serialisation.php in create-send-php/class/

    Also there is an error in the widget html in cm-ajax-widget.php line 131 must be put on line 127 to form valid html

  3. Lee Willis
    Member
    Plugin Author

    Posted 3 years ago #

    @indigoclothing - sorry - just seen this. I'm guessing you're on PHP < 5.2. I'm pretty sure I'm gonna mark PHP 5.2 as a pre-req for this as the alternative is pretty complex.

    @timvanoostrom - Thanks for the note - I've just pushed out 0.6 which fixes this.

  4. indigoclothing
    Member
    Posted 3 years ago #

    Am using PHP 5.2.14?

  5. Lee Willis
    Member
    Plugin Author

    Posted 3 years ago #

    tim's fix mentioned earlier in the thread will *probably* work - but I'm interested in diagnosing the issue properly - can you drop me a note here:

    http://www.leewillis.co.uk/contact/

  6. timvanoostrom
    Member
    Posted 3 years ago #

    You could do :

    if(!class_exists('Services_JSON')) {
    require_once 'services_json.php';
    }

    But dunno if that piece of code is yours..

  7. Lee Willis
    Member
    Plugin Author

    Posted 3 years ago #

    It's not - it's part of the CampaignMonitor sample API code - but that's not really the issue.

    As I understand it that class should only be created if native PHP JSON support isn't available (At least I think that's what WordPress does - I haven't investigated fully). So - if WP is defining it then it thinks JSON support isn't available.

    More importantly if another plugin is defining the class it might not necessarily have the required methods available - so we may still need to define something!

    Anyway - I've got the OPs details so I'll have an investigate and report back when I've got a conclusion...

  8. timvanoostrom
    Member
    Posted 3 years ago #

    I had the same problem.

    The require_once should not do anything if the file is already required(included) before. I guess in my php (>5.3) installation the file is not implemented by inclusion but "built in" or something.

    So what happens is php is including a file and finds a class that is already made available, though not by inclusion thus throwing the error in op.

  9. Lee Willis
    Member
    Plugin Author

    Posted 3 years ago #

    So, PHP 5.2 includes "json functions" by default, but not a class called 'Services_JSON'.

    WordPress (In wp-includes/compat.php) checks if the JSON functions are present, and if they're NOT then it includes a file that generates it's own copy of Services_JSON (Incidentally, the same code, but a newer version than I'm supplying).

    My plugin blindly includes Services_JSON whether it's needed or not.

    So - first step - I'm going to make the change Tim suggested (Namely, only include the class if it hasn't already been included).

    My fear is that that may "work" but other stuff may fail due to differences between the two versions of Services_JSON.

    What I'm puzzled about in your cases is why WordPress is including Services_JSON at all since the JSON functions are included in 5.2 natively (Unless I guess they've been compiled out).

  10. indigoclothing
    Member
    Posted 3 years ago #

    Thanks for your help Lee - your new version fixed it :)

  11. Lee Willis
    Member
    Plugin Author

    Posted 3 years ago #

    Great news!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic