Hi,
I want to report a bug in serendipity_event_includeentry plugin. I am using Serendipity 1.7-rc3 and PHP 5.3.1 with SQLite DB.
From the Serendipity Administration UI, if I go to "Configure Plugins", select "Show random blocks" to Yes and Save, and then if I go to "Back to Weblog" , it shows the following :
== TESTING ERROR MODE ==
Fatal error: Uncaught exception 'ErrorException' with message 'Serendipity error: sqlite_query() [<a href='function.sqlite-query'>function.sqlite-query</a>]: no such function: RAND' in D:\Mangesh\xampp\htdocs\serendipity\include\compat.inc.php:118
Stack trace:
#0 [internal function]: errorToExceptionHandler(2, 'sqlite_query() ...', 'D:\Mangesh\xamp...', 233, Array)
#1 D:\Mangesh\xampp\htdocs\serendipity\include\db\sqlite.inc.php(233): sqlite_query('SELECT *? ...', Resource id #18)
#2 D:\Mangesh\xampp\htdocs\serendipity\plugins\serendipity_event_includeentry\serendipity_event_includeentry.php(420): serendipity_db_query('SELECT *? ...', true, 'assoc', 1)
#3 D:\Mangesh\xampp\htdocs\serendipity\plugins\serendipity_event_includeentry\serendipity_event_includeentry.php(684): serendipity_event_includeentry->fetchStaticBlocks('block', 'RAND()', 1)
#4 D:\Mangesh\xampp\htdocs\serendipity\include\plugin_api.inc.php(1073): serendipity_event_includeentry->event_hook('frontend_displa...', Object(serendipity_property_bag), Arr in D:\Mangesh\xampp\htdocs\serendipity\include\compat.inc.php on line 118
This error shows up because probably there is no RAND function in SQLite. So we need to change it to RANDOM instead of RAND for SQLite..
- Mangesh Gokhale
serendipity_event_includeentry - Show RANDOM blocks
-
- Posts: 2
- Joined: Fri Mar 01, 2013 10:18 am
Re: serendipity_event_includeentry - Show RANDOM blocks
Thanks for noting!
Could you try to replace the
$this->staticblock = $this->fetchStaticBlocks('block', 'RAND()', 1);
at line ~684 in serendipity_event_includeentry.php with thisand see if that works, please?
Could you try to replace the
$this->staticblock = $this->fetchStaticBlocks('block', 'RAND()', 1);
at line ~684 in serendipity_event_includeentry.php with this
Code: Select all
if (stristr($serendipity['dbType'], 'sqlite') === FALSE) {
$this->staticblock = $this->fetchStaticBlocks('block', 'RAND()', 1);
} else {
$this->staticblock = $this->fetchStaticBlocks('block', 'RANDOM()', 1);
}
Regards,
Ian
Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Ian
Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
-
- Posts: 2
- Joined: Fri Mar 01, 2013 10:18 am
Re: serendipity_event_includeentry - Show RANDOM blocks
Hi Ian.
I replaced the code and it works now.
Thanks a lot.
Mangesh
I replaced the code and it works now.
Thanks a lot.
Mangesh
Re: serendipity_event_includeentry - Show RANDOM blocks
Thank you!
Garvin, is that the way to go, since we have sqlite, sqlite3 and pdo-sqlite?
I don't really know if that does have to fit to all three ....?!
I also found http://jan.kneschke.de/projects/mysql/order-by-rand/ which should be worth to note about optimizing that RAND query.
Garvin, is that the way to go, since we have sqlite, sqlite3 and pdo-sqlite?
I don't really know if that does have to fit to all three ....?!
I also found http://jan.kneschke.de/projects/mysql/order-by-rand/ which should be worth to note about optimizing that RAND query.
Regards,
Ian
Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Ian
Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Re: serendipity_event_includeentry - Show RANDOM blocks
Hi Ian
I think i can answer that for you. This is a candiate for a {RANDOM}-Variable in serendipity_db_schema_import. But to fix the plugin for the time being, you should probably indeed catch all sqlite-dbType: 'sqlite', 'sqlite3', 'pdo-sqlite'.
But: afaik RAND() is mysql-specific, postgresql also uses RANDOM. So we should write it the other way around:
I think i can answer that for you. This is a candiate for a {RANDOM}-Variable in serendipity_db_schema_import. But to fix the plugin for the time being, you should probably indeed catch all sqlite-dbType: 'sqlite', 'sqlite3', 'pdo-sqlite'.
But: afaik RAND() is mysql-specific, postgresql also uses RANDOM. So we should write it the other way around:
Code: Select all
if (mysql)
RAND
else
RANDOM