Surge-ee / Surgedown

A Markdown fieldtype
17 stars 3 forks source link

Cannot redeclare Markdown() when iterating over multiple entries. #10

Open JamesMcFall opened 11 years ago

JamesMcFall commented 11 years ago

Gidday, I just downloaded this plugin to use as the main content field for a blog and it works fine when dealing with one single channel entry (ie when I'm outputting a featured post or on the actual article page).

On the listing page however, as soon as the channel entry loop runs multiple times php throws a fatal error:


Fatal error: Cannot redeclare Markdown() (previously declared in xx/system/expressionengine/third_party/markdown/library/markdown.php:43) in xx/system/expressionengine/third_party/markdown/library/markdown.php on line 56

Example:

{exp:channel:entries channel="blog" dynamic="no"}
    {blog_post}
{/exp:channel:entries}

Or even:

{exp:channel:entries channel="blog" dynamic="no" limit="1"}
    {blog_post}
{/exp:channel:entries}
{exp:channel:entries channel="blog" dynamic="no" limit="1" offset="1"}
    {blog_post}
{/exp:channel:entries}
JamesMcFall commented 11 years ago

And it occurs for every single method and constant defined in xx/system/expressionengine/third_party/markdown/library/markdown.php

fideloper commented 11 years ago

Hi!

I've been a bad OS maintainer and haven't paid much attention to this field much - I think there are some bugs with this custom field with newer versions of EE. I may have some time to look at this in the coming days, but I'd recommend taking a look at: http://devot-ee.com/add-ons/smartdown

That being said - does this occur for you in the admin control panel only? Or also in the front end? Lastly, what version of PHP are you running?

Thanks!

JamesMcFall commented 11 years ago

Gidday fideloper, Thanks for getting back to me.

This error doesn't occur on the admin panel at all, it's actually just on the front end when I'm trying to iterate through posts with the EE tags. The back end is fine.

I'm running php 5.4.X (I'm at work so don't have the exact version on me) and yeah EE is 2.5.5 or whatever the current latest is.

As an immediate workaround I just wrapped the class and function declarations in conditionals checking if they aren't declared before doing so. It's messy but it works :)

I'll have a little look at Smartdown later too but you've spent the time building the plugin, I wouldn't give up on maintaining it after you've done all that work!

Thanks!

fdelaneau commented 11 years ago

Same behavior here. You can define as many Markdown fields as you like the backend won't bulge but calling any other Markdown field then the first one crashes the front-end :(