CDbException: The DB query must contain the "from" portion Seeing the above error, somewhat sporadically, and can't seem to track it down.

Here's the full log entry:

2014/07/03 15:17:22 [error] [exception.CDbException] exception 'CDbException' with message 'The DB query must contain the "from" portion.' in /var/www/topsecret.co.uk/craft/app/framework/db/CDbCommand.php:566
Stack trace:
#0 /var/www/topsecret.co.uk/craft/app/framework/db/CDbCommand.php(160): CDbCommand-&gt;buildQuery(Array)
#1 /var/www/topsecret.co.uk/craft/app/framework/db/CDbCommand.php(484): CDbCommand-&gt;getText()
#2 /var/www/topsecret.co.uk/craft/app/framework/db/CDbCommand.php(415): CDbCommand-&gt;queryInternal('fetch', Array, Array)
#3 /var/www/topsecret.co.uk/craft/app/etc/behaviors/AppBehavior.php(410): CDbCommand-&gt;queryRow()
#4 /var/www/topsecret.co.uk/craft/app/etc/behaviors/AppBehavior.php(146): Craft\AppBehavior-&gt;getInfo('edition')
#5 [internal function]: Craft\AppBehavior-&gt;getEdition()
#6 /var/www/topsecret.co.uk/craft/app/framework/base/CComponent.php(261): call_user_func_array(Array, Array)
#7 /var/www/topsecret.co.uk/craft/app/services/LocalizationService.php(111): CComponent-&gt;__call('getEdition', Array)
#8 /var/www/topsecret.co.uk/craft/app/services/LocalizationService.php(111): Craft\WebApp-&gt;getEdition()
#9 /var/www/topsecret.co.uk/craft/app/services/LocalizationService.php(141): Craft\LocalizationService-&gt;getSiteLocales()
#10 /var/www/topsecret.co.uk/craft/app/services/LocalizationService.php(154): Craft\LocalizationService-&gt;getPrimarySiteLocale()
#11 /var/www/topsecret.co.uk/craft/app/etc/web/WebApp.php(824): Craft\LocalizationService-&gt;getPrimarySiteLocaleId()
#12 /var/www/topsecret.co.uk/craft/app/etc/web/WebApp.php(291): Craft\WebApp-&gt;_getTargetLanguage()
#13 /var/www/topsecret.co.uk/craft/app/framework/i18n/CMessageSource.php(83): Craft\WebApp-&gt;getLanguage()
#14 /var/www/topsecret.co.uk/craft/app/framework/YiiBase.php(585): CMessageSource-&gt;translate('yii', 'The DB query mu...', NULL)
#15 /var/www/topsecret.co.uk/craft/app/framework/db/CDbCommand.php(566): YiiBase::t('yii', 'The DB query mu...')
#16 /var/www/topsecret.co.uk/craft/app/framework/db/CDbCommand.php(160): CDbCommand-&gt;buildQuery(Array)
#17 /var/www/topsecret.co.uk/craft/app/framework/db/CDbCommand.php(484): CDbCommand-&gt;getText()
#18 /var/www/topsecret.co.uk/craft/app/framework/db/CDbCommand.php(415): CDbCommand-&gt;queryInternal('fetch', Array, Array)
#19 /var/www/topsecret.co.uk/craft/app/etc/behaviors/AppBehavior.php(410): CDbCommand-&gt;queryRow()
#20 /var/www/topsecret.co.uk/craft/app/etc/behaviors/AppBehavior.php(371): Craft\AppBehavior-&gt;getInfo('maintenance')
#21 [internal function]: Craft\AppBehavior-&gt;isInMaintenanceMode()
#22 /var/www/topsecret.co.uk/craft/app/framework/base/CComponent.php(261): call_user_func_array(Array, Array)
#23 /var/www/topsecret.co.uk/craft/app/etc/web/WebApp.php(145): CComponent-&gt;__call('isInMaintenance...', Array)
#24 /var/www/topsecret.co.uk/craft/app/etc/web/WebApp.php(145): Craft\WebApp-&gt;isInMaintenanceMode()
#25 /var/www/topsecret.co.uk/craft/app/framework/base/CApplication.php(180): Craft\WebApp-&gt;processRequest()
#26 /var/www/topsecret.co.uk/craft/app/index.php(196): CApplication-&gt;run()
#27 /var/www/topsecret.co.uk/web/index.php(17): require_once('/var/www/topse...')
#28 {main}


Looking through that I'm not seeing any references to any custom plugins or templates so wonder if it's a bug...

Any suggestions would be very much appreciated!
Traced the error back to the from function in Yii's craft/app/framework/db/CDbCommand.php:

$tables=preg_split('/\s*,\s*/u',trim($tables),-1,PREG_SPLIT_NO_EMPTY);


The preg_split documentation states "if matching fails, an array with a single element containing the input string will be returned" but I was just getting an empty array.

This made me suspicious of what the PREG_SPLIT_NO_EMPTY flag was hiding, sure enough without it I got an array with one empty string in it, as if there was a match.

Some trial and error later and adding the PCRE_UTF8 modifier u to the preg_split patterns seemed to solve the problem.

Unfortunately can't explain what's causing the encoding issues yet.