• Resolved hamstair_toilichte

    (@hamstair_toilichte)


    I installed the free version of EasyTestimonials on a site I manage, and when I activated it immediately got the error:

    `Fatal error: Cannot redeclare class randomTestimonialWidget in /home/workfu01/public_html/wp-content/plugins/easy-testimonials/include/widgets/random_testimonial_widget.php on line 290

    This appeared on all site pages making the site unusable, so I hastily deleted the plugin files manually and the site returned to normal. As a PHP developer I know in general what causes this error, but I can’t see what on this site is causing it. I’ve looked at the offending file cited above, and line 290 is the very end of the script! The class randomTestimonialWidget only appears once, as it should do. The site uses the Increase theme by ThemeForest, which has a testimonials feature built in, so I thought that perhaps there’s a class name clash with that, so I grepped the theme files for ‘randomTestimonialWidget‘ without result. I even grepped the whole site but the string didn’t appear in any files.

    I know that the plugin works as I’d tested it on my personal site beforehand, and of course there are 00s of 000s of plugin users. I googled the error and only got one hit, a forum post which was unanswered.

    Can anyone suggest what might be causing this name clash? I feel instinctively that it’s a clash with the theme but as ‘randomTestimonialWidget’ does not appear in any of the scripts I can’t see why.

    I know that I could disable plugins one by one, and switch themes, to try to diagnose the problem, but a) Workfuture is a live site which I can’t fiddle about with, and b) we’re purely evaluating EasyTestimonials and I’m not going to spend hours trying to fix a test installation. Normally, with a plugin that doesn’t work for me, I’d move on and try to find another plugin with similar functionality. However, I and my client rather like EasyTestimonials, and the error is technically bugging me as it’s not one that I’ve ever come across with WordPress, which I’ve been using for many years.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor richardgabriel

    (@richardgabriel)

    Hey @hamstair_toilichte!

    That reads like there is a duplicate classname somewhere within the Theme, or another plugin, on your site.

    I would recommend trying to change the class name in our widget and see what that does — there are a few locations the change would need to be made.

    Likely, we can permanently address this via a quick bug fix later this week.

    All the best,
    Richard

    Thread Starter hamstair_toilichte

    (@hamstair_toilichte)

    Thanks for the comeback. Yes, I figured that must be the case, and the theme with its testimonials functionality would be the most likely culprit, so I was surprised when a grep of all the site files for randomTestimonialWidget came up empty. Mind you, I had to grep from the hosting account cpanel, as there’s no shell access to the account as it’s on a shared server.

    My knowledge of WordPress plugin and theme development is at beginner level. I thought that each plugin only operated in its own ‘box’, so that any classes and variables would be seen only by that plugin, but clearly that’s wrong.

    I doubt that this problem is a ‘bug’ with your plugin, as if it were a search for the error would have harvested a heap of hits, rather than just one. Plus your plugin is very widely and successfully used, so it’s almost certainly a problem with my site and its theme. I just posted here in case the problem might have rung a bell with someone.

    Plugin Contributor richardgabriel

    (@richardgabriel)

    Hey @hamstair_toilichte!

    My apologies for basically restating what you had already determined.

    I was also suggesting that you rename our widget’s classname and the corresponding line of code where it is registered, to help you get up and running. I’m happy to point you in the right direction.

    Unfortunately, WordPress supports as low as PHP 5.2 (which itself does not support namespaces.) This entire issue would be avoided if we had those! We’ll make a note to update our classnames to prevent future occurrences of issues like these, as well.

    All the best,
    Richard

    Thread Starter hamstair_toilichte

    (@hamstair_toilichte)

    No apologies needed, Richard. Thanks for replying to a non-paying customer ??

    If the classname is just registered in one line of code then sure, that’d be easy enough to tweak. In your previous reply, though, you wrote “there are a few locations the change would need to be made” which put me off a bit. Do please point me in the right direction, and I’ll give it a go. We don’t need random testimonials so I can do without the class altogether.

    I wasn’t aware that namespaces were a big thing in the latest PHP versions – live and learn. Mind you, I only write lightweight scripts these days.

    Plugin Contributor richardgabriel

    (@richardgabriel)

    Hey @hamstair_toilichte

    I don’t see my last reply here, as I clean up tickets today… Weird.

    Anyways, you would want to edit the ‘easy_testimonials_register_widgets’ function’s register_widget call to match the new classname, and then you would also want to update the random_testimonial_widget.php classname to match.

    Since you don’t plan on using the widget, you could also comment out the include to it and the register_widget call in the easy_testimonials_register_widgets function, too, and that would fix things.

    I hope that helps!

    Best,
    Richard

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘randomTestimonialWidget error’ is closed to new replies.