Support » Plugin: Campaign Monitor Ajax Forms » [Plugin: Campaign Monitor Ajax Forms] When trying to activate – fatal error

  • Resolved indigoclothing


    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

Viewing 10 replies - 1 through 10 (of 10 total)
  • 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

    Plugin Author Lee Willis


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

    Am using PHP 5.2.14?

    Plugin Author Lee Willis


    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:


    You could do :

    if(!class_exists(‘Services_JSON’)) {
    require_once ‘services_json.php’;

    But dunno if that piece of code is yours..

    Plugin Author Lee Willis


    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…

    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.

    Plugin Author Lee Willis


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

    Thanks for your help Lee – your new version fixed it 🙂

    Plugin Author Lee Willis


    Great news!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘[Plugin: Campaign Monitor Ajax Forms] When trying to activate – fatal error’ is closed to new replies.