e107inc / e107

e107 Bootstrap CMS (Content Management System) v2 with PHP, MySQL, HTML5, jQuery and Twitter Bootstrap. Issue Discussion Room: https://gitter.im/e107inc/e107
https://e107.org
GNU General Public License v3.0
321 stars 213 forks source link

Fatal Error with User_Shortcodes.php with non-bootstrap themes #546

Closed NZMikey closed 10 years ago

NZMikey commented 10 years ago

Any theme i attempt to use (Including freshly created themes from myself) that dont use bootstrap, return in a fatal error as below:

Fatal error: Out of memory (allocated 82575360) (tried to allocate 65484 bytes) in /homepages/NewSite/e107_core/shortcodes/batch/user_shortcodes.php on line 316

NZMikey commented 10 years ago

In said line, there was some new code added there specifically for bootstrap, once removing it, it worked once again. Not a fix so to speak, just a direction.

Moc commented 10 years ago

Confirmed.

This is due to a loop in the function. On line 316 of user_shortcodes.php:

return ($boot) ? "<i class='icon-user'></i>" : $this->sc_user_icon();   

the sc_user_icon method is called again because no $parm value has been given. It continues to loop until memory has run out.

Will look into a fix for this

Jimmi08 commented 10 years ago

You should have in your theme: define("BOOTSTRAP", '');

Moc commented 10 years ago

No, that would require all v1 themes to have that as well (I think). All bootstrap themes should have that define in there, but not all non-bootstrap themes.

Jimmi08 commented 10 years ago

it was quick fix, something like adjust your theme for v2. If e107 is bootstrap CMS, it should be required to have main bootstrap variable defined.
Rewrite this in one line, if you want: (line 277) if(deftrue('BOOTSTRAP')) { $boot = deftrue('BOOTSTRAP'); } else { $boot = FALSE; }

This works too. This test is used in 35 files, maybe only here is forgotten.

I tried (dislike this way of coding), check it, please. $boot = (deftrue('BOOTSTRAP')) ? deftrue('BOOTSTRAP') : FALSE;

Moc commented 10 years ago

Are you sure that's the problem? I think it will not change anything, The problem is that when not using a bootstrap theme, the method sc_user_icon will call sc_user_icon over and over again as no $parm is defined.

return ($boot) ? "<i class='icon-user'></i>" : $this->sc_user_icon();

It loops as it calls the same method again (and again)

I'm going to commit the fix which should make things clearer.

Moc commented 10 years ago

The commit I pushed will fix the loop. The only issue that remains is the missing user_realname.png image.

Moc commented 10 years ago

Fixed the image as well. @NZMikey Please update the files and see if the issue is resolved for you :)