I have a very strange issue occurring, perhaps due to some type of caching. I’m attempting to build my first plugin and I need to load a third party module from within my plugin. In this case it’s the Channel Ratings module from DevDemon, but I’m not sure that fact matters. I load the module like so:
$this->EE->load->add_package_path(PATH_THIRD.'channel_ratings/');
require(PATH_THIRD.'channel_ratings/mod.channel_ratings.php');
$objChannelRatings = new Channel_ratings();Then, to test that this is working properly, I make a simple call to a function, in which I’m returning a simple string:
return $objChannelRatings->testing();I set the testing() function to return a test string, “AAA”, and this is then output to the screen. When I load my browser the first time I get an error:
Fatal error: Cannot redeclare class channel_ratings in /path/to/expressionengine/third_party/channel_ratings/mod.channel_ratings.php on line 13
But then when I refresh my browser again, it works just fine and the error is gone from any future reloads. The error only occurs the first time I load the page. That is, until I change the testing() function to return a different test string, like “BBB”. Every time I change the output of the function, the first page load with yield the error but then all page loads after that work just fine.
This behavior happens in Firefox on Mac. Chrome for Mac acts the same way but instead of seeing the error I am getting a 500 Internal Server Error instead.
Does this behavior make sense to anyone? I don’t think it has anything to do with the coding of the module itself but I suppose I could be wrong.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.