XH 1.6: Wrong inclusion of FileEdit.php in TinyMCE-Plugin

A place to report and discuss bugs - please mention CMSimple-version, server, platform and browser version
Post Reply
Holger
Site Admin
Posts: 3470
Joined: Mon May 19, 2008 7:10 pm
Location: Hessen, Germany

XH 1.6: Wrong inclusion of FileEdit.php in TinyMCE-Plugin

Post by Holger » Mon Feb 17, 2014 9:11 pm

Hi,

in /plugins/tinymce/admin.php the following code

Code: Select all

include $pth['folder']['classes'] . 'FileEdit.php';
must be changed to include_once or require_once to prevent a fatal error (cannot redeclare a existing class) when another plugin tries to include the file too.

manu
Posts: 1090
Joined: Wed Jun 04, 2008 12:05 pm
Location: St. Gallen - Schweiz
Contact:

Re: XH 1.6: Wrong inclusion of FileEdit.php in TinyMCE-Plugi

Post by manu » Tue Feb 18, 2014 12:24 pm

Holger wrote:Hi,

in /plugins/tinymce/admin.php the following code

Code: Select all

include $pth['folder']['classes'] . 'FileEdit.php';
must be changed to include_once or require_once to prevent a fatal error (cannot redeclare a existing class) when another plugin tries to include the file too.
Indeed, Holger, there should be a include_once.
In the short turn, I'll fix it in the trunk, in the long term I recode the admin part without extended FileEdit class.
regards
manu

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: XH 1.6: Wrong inclusion of FileEdit.php in TinyMCE-Plugi

Post by cmb » Tue Feb 18, 2014 12:41 pm

manu wrote:Indeed, Holger, there should be a include_once.
ACK. Generally, classes and pure procedural files should be included/required _once, IMO, opposed to pure data files (such as config.php). It's not so clear to me how to treat files containing global code and definitions, such as index.php and admin.php of plugins. Traditionally, they are simply include'd.

To work around issues with XH 1.6/1.6.1 one might use the following in other plugins:

Code: Select all

if (!class_exists('XH_FileEdit')) {
    include_once $pth['folder']['classes'] . 'FileEdit.php';
}
Christoph M. Becker – Plugins for CMSimple_XH

manu
Posts: 1090
Joined: Wed Jun 04, 2008 12:05 pm
Location: St. Gallen - Schweiz
Contact:

Re: XH 1.6: Wrong inclusion of FileEdit.php in TinyMCE-Plugi

Post by manu » Tue Feb 18, 2014 7:41 pm

Ok, I recoded admin.php to omit extended classes of FileEdit Classes (Rev. 1212). This was a constriction site anyway.
Regards
manu

Post Reply