1

Hi guys I'm having trouble with a site I just took live. I had it running on MAMP without issues and now I'm getting errors regarding the headings_rte. This is the one that is most persistent:

Fatal error: include(): Cannot redeclare class headings_rte in /srv/www/domain.com/sys/expressionengine/modules/rte/models/rte_tool_model.php on line 155

I couldn't find anything via Google or in the EllisLab forums.

3
  • What version of EE are you running? In my copy of 2.5.3, that line of that file uses include_once(), not include(), so this error shouldn't appear if indeed a file is being included more than once for some reason. Dec 20 '12 at 3:04
  • Hey Derek. I'm running EE 2.5.4 and the code in the rte_tool_model.php does use the include_once() statement. I'm not sure why it says include() on the error page.
    – dikaio
    Dec 20 '12 at 5:59
  • I am seeing the same issue on our end. I have gone through and debugged how it is including the different classes in this process, and can not see how it would try to even include the file again. However we are using APC and when it was flushed this worked for a few requests then the error came back. Did you ever find out how to resolve this?
    – sudopratt
    Sep 27 '13 at 16:42
1

My first suggestion is to reupload all files to the server. You can start with all files under the /srv/www/domain.com/sys/expressionengine/modules/rte/ directory. Something could be missing or was corrupted on upload.

My second suggestion is to make sure you are running the latest version of EE and addons. EL just released a new version so upgrading may solve your error.

My third suggestion is to look at line 155 of that file to see what the code is doing. That might give you some hints. It's very possible the issue is related to your server environment since no one has reported the error anywhere. Here are links to other "Fatal error: include(): Cannot redeclare class" errors.. Not the same specific file errors but these might offer some clues:

https://stackoverflow.com/questions/5611219/fatal-error-cannot-redeclare-class-customer

https://stackoverflow.com/questions/708140/php-fatal-error-cannot-redeclare-class

https://stackoverflow.com/questions/12222305/fatal-error-cannot-redeclare-class-net-ssh2-in-var-www-phpseclib-net-ssh2-php

1
  • Hi Anna. Unfortunately that didn't work for me, I did try doing that prior to posting here, I'm sorry I should have posted that with the initial question. I also did a complete reinstall using new EE files and a new database, the only thing I kept was my template files. As for addons all are up to date but the error is coming from the default tools and not add ons which is strange.
    – dikaio
    Dec 20 '12 at 5:54
1

Ok guys figured this out but don't know why it's happened in the first place but all I did was uninstall all modules and reinstalled and now there error does not pop up.

1
  • Spoke to soon... I didn't add the standard tools e.g. checkboxes, drop downs, etc so once I did and when I tried to create a new field it redirected me to the error statement above.
    – dikaio
    Dec 20 '12 at 7:11
1

You need to put classes into "library" files (as opposed to "code" files) and always do require_once or include_once on them. Once you separate code from libraries, the next logical step is to switch to using autoloader mechanism of PHP.

If not possible, then put wrapper around the classes you are loading:

if (class_exists('headings_rte') != true) {   
    class headings_rte { ... }
}

ah, and never mix autoloading with explicit require_once - this is recipe for trouble.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.