Bug with global $TABLE_PREFIX - please confirm

4 posts by 2 authors in: Forums > CMS Builder
Last Post: February 25, 2008   (RSS)

By webdude - February 22, 2008

Hi There,

I just noticed that when I call getListRows($options) from a different scope (eg within a function) that the table prefix doesn't automatically get prepended producing an error like this: List Viewer (news): MySQL Error: Table 'cmsbuilder.news' doesn't exist It should be looking for the table cmsbuilder.cms_news and not cmsbuilder.news

I traced it back to the CMS Builder source code. It looks like CMS Builder wasn't properly setting $TABLE_PREFIX internally. I found a quick solution...

The original line 91 of lib/init.php:
$TABLE_PREFIX =& $SETTINGS['mysql']['tablePrefix'];

FIX by changing line 91 of lib/init.php to this:
$TABLE_PREFIX = $SETTINGS['mysql']['tablePrefix'];

I was hoping to get an official response from support to confirm that this won't break something else. Perhaps the =& in the code wasn't really intentional.

Thanks for the amazing product BTW!

Re: [webdude] Bug with global $TABLE_PREFIX - please confirm

By Dave - February 22, 2008

Hi webdude,

Thanks for the heads up on that. Using = instead of =& shouldn't cause any problems.

I can't reproduce this locally. What version of PHP are you using? Would you mind emailing me (at dave@interactivetools.com) the code in question so I could have a look? I'd like to reproduce and fix it for the next version if possible.

Are you using $TABLE_PREFIX directly anywhere else? I thought the "global $TABLE_PREFIX" at the top of getListRows() would have it access the global. It's strange that it's blanking out for you.

Thanks! :)
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Bug with global $TABLE_PREFIX - please confirm

By webdude - February 22, 2008

OK thanks Dave I sent you an email with code to reproduce!