Recent entries error

Found a bug? Tell us!!
plofhead
Regular
Posts: 45
Joined: Fri Jun 23, 2006 9:01 am
Location: Netherlands
Contact:

Recent entries error

Post by plofhead »

Since I updated Serendipity from version 1.0.2 to 1.1 my Recent Entries sidebar plugin doesn't work anymore as it should. It always shows the defined number of entries starting from the very first entry I made. Show all doesn't make any difference. I'm using version 1.6.
By the way: I can't find the plugin anymore on the plugins page!

Regards,
Bert
To bee or not to bee, that is the question
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Recent entries error

Post by garvinhicking »

Hi!

Can you make a screenshot of your plugin page? It should be there!?

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
plofhead
Regular
Posts: 45
Joined: Fri Jun 23, 2006 9:01 am
Location: Netherlands
Contact:

Post by plofhead »

Hi Garvin,

I was looking for an update of the Recent Entries plugin. I mean that I can't find the Recent Entries plugin anymore on the s9.org website.
The plugin on my own serendipity administration is visable, but on my blog it's always showing the first entries I ever made i.s.o. the latest ones. No matter what I setup in the plugin.

Look at www.plofhead.nl

Regards,
Bert
To bee or not to bee, that is the question
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Ah, okay. "Recent entries" is bundled with Serendipity itself, so it is not available on spartacus.

How do you have the plugin currently configured exactly? I'd like to fix the bug, so I'd like to try it with your exact current settings?

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
plofhead
Regular
Posts: 45
Joined: Fri Jun 23, 2006 9:01 am
Location: Netherlands
Contact:

Post by plofhead »

Hi Garvin,

I configured it like this:
Name: Recent entries
Number of entries: 10
Skip front page entries: I enabled Skip front page entries
Date: %A, %B %e %Y
Category: All categories

I tried several other settings but always it's always starting with the oldest entry.

Hope this helps.

Regards,
Bert
To bee or not to bee, that is the question
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Hm, with those settings it works on my testblog. Could you please edit your serendipity_plugin_recententries.php file and search for this:

Code: Select all

        $entries_query = "SELECT DISTINCT id,
                                                title,
                                                timestamp
                                           FROM {$serendipity['dbPrefix']}entries
                                                $sql_join
                                          WHERE isdraft = 'false' AND timestamp <= " . time() . "
                                                $sql_where
                                       ORDER BY timestamp DESC
                                                $sql_number";
This query seems to be faulty and we need to check why. So after that line please insert

Code: Select all

echo $entries_query;
and save the file, then reload your blog and copy the query that is now displayed in the sidebar and show it here to me. You can then remove the echo-statement again to not uglify your blog.

With the SQL output I hope to be able to see what might be going on!

HTH,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
plofhead
Regular
Posts: 45
Joined: Fri Jun 23, 2006 9:01 am
Location: Netherlands
Contact:

Post by plofhead »

Hi Garvin,

This is what appears:
?php # $Id: serendipity_plugin_recententries.php 1117 2006-04-19 03:28:40Z slothman $ // Contributed by Christian Machmeier // Probe for a language include with constants. Still include defines later on, if some constants were missing $probelang = dirname(__FILE__) . '/' . $serendipity['charset'] . 'lang_' . $serendipity['lang'] . '.inc.php'; if (file_exists($probelang)) { include $probelang; } include dirname(__FILE__) . '/lang_en.inc.php'; class serendipity_plugin_recententries extends serendipity_plugin { var $title = PLUGIN_RECENTENTRIES_TITLE; function introspect(&$propbag) { $this->title = $this->get_config('title', $this->title); $propbag->add('name', PLUGIN_RECENTENTRIES_TITLE); $propbag->add('description', PLUGIN_RECENTENTRIES_BLAHBLAH); $propbag->add('stackable', true); $propbag->add('author', 'Christian Machmeier'); $propbag->add('version', '1.6'); $propbag->add('requirements', array( 'serendipity' => '0.8', 'smarty' => '2.6.7', 'php' => '4.1.0' )); $propbag->add('configuration', array('title', 'number', 'number_from', 'dateformat', 'category')); $propbag->add('groups', array('FRONTEND_VIEWS')); } function introspect_config_item($name, &$propbag) { switch($name) { case 'title': $propbag->add('type', 'string'); $propbag->add('name', TITLE); $propbag->add('description', TITLE_FOR_NUGGET); $propbag->add('default', PLUGIN_RECENTENTRIES_TITLE); break; case 'number': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_RECENTENTRIES_NUMBER); $propbag->add('description', PLUGIN_RECENTENTRIES_NUMBER_BLAHBLAH); $propbag->add('default', 10); break; case 'number_from': $propbag->add('type', 'radio'); $propbag->add('name', PLUGIN_RECENTENTRIES_NUMBER_FROM); $propbag->add('description', PLUGIN_RECENTENTRIES_NUMBER_FROM_DESC); $propbag->add('radio', array( 'value' => array('all', 'skip'), 'desc' => array(PLUGIN_RECENTENTRIES_NUMBER_FROM_RADIO_ALL, PLUGIN_RECENTENTRIES_NUMBER_FROM_RADIO_RECENT) )); $propbag->add('default', 'all'); break; case 'dateformat': $propbag->add('type', 'string'); $propbag->add('name', GENERAL_PLUGIN_DATEFORMAT); $propbag->add('description', sprintf(GENERAL_PLUGIN_DATEFORMAT_BLAHBLAH, '%A, %B %e %Y')); $propbag->add('default', '%A, %B %e %Y'); break; case 'category': $cats = serendipity_fetchCategories($serendipity['authorid']); if (!is_array($cats)) { return false; } $catlist = serendipity_generateCategoryList($cats, array(0), 4, 0, 0, '', ' . '); $tmp_select_cats = explode('@@@', $catlist); if (!is_array($tmp_select_cats)) { return false; } $select_cats = array(); $select_cats['none'] = ALL_CATEGORIES; foreach($tmp_select_cats as $cidx => $tmp_select_cat) { $select_cat = explode('|||', $tmp_select_cat); if (!empty($select_cat[0]) && !empty($select_cat[1])) { $select_cats[$select_cat[0]] = $select_cat[1]; } } $propbag->add('type', 'multiselect'); $propbag->add('select_values', $select_cats); $propbag->add('select_size', 5); $propbag->add('name', CATEGORY); $propbag->add('description', CATEGORIES_TO_FETCH); $propbag->add('default', 'none'); break; default: return false; } return true; } function generate_content(&$title) { global $serendipity; $number = $this->get_config('number'); $dateformat = $this->get_config('dateformat'); $category = $this->get_config('category', 'none'); $title = $this->get_config('title', $this->title); $number_from_sw = $this->get_config('number_from'); $sql_join = ''; $sql_where = ''; if ($category != 'none') { $sql_join = 'LEFT OUTER JOIN ' . $serendipity['dbPrefix'] . 'entrycat AS ec ON id = ec.entryid LEFT OUTER JOIN ' . $serendipity['dbPrefix'] . 'category AS c ON ec.categoryid = c.categoryid'; $sql_categories = array(); if (is_numeric($category)) { $sql_categories[] = $category; } else { $sql_categories = explode('^', $category); } $category_parts = array(); foreach($sql_categories AS $sql_category) { $category_parts[] = "\n" . implode(' AND ', serendipity_fetchCategoryRange($sql_category)); } $sql_where = ' AND (c.category_left BETWEEN ' . implode(' OR c.category_left BETWEEN ', $category_parts) . ')'; } if (!$number || !is_numeric($number) || $number < 1) { $number = 10; } $sql_number = serendipity_db_limit_sql($number); switch($number_from_sw) { case 'skip': $sql_number = serendipity_db_limit_sql(serendipity_db_limit($serendipity['fetchLimit'], $number)); break; } if (!$dateformat || strlen($dateformat) < 1) { $dateformat = '%A, %B %e %Y'; } $entries_query = "SELECT DISTINCT id, title, timestamp FROM {$serendipity['dbPrefix']}entries $sql_join WHERE isdraft = 'false' AND timestamp <= " . time() . " $sql_where ORDER BY timestamp DESC $sql_number"; echo $entries_query; $entries = serendipity_db_query($entries_query); if (isset($entries) && is_array($entries)) { foreach ($entries as $k => $entry) { $entryLink = serendipity_archiveURL( $entry['id'], $entry['title'], 'serendipityHTTPPath', true, array('timestamp' => $entry['timestamp']) ); if (empty($entry['title'])) { $entry['title'] = '#' . $entry['id']; } echo '' . $entry['title'] . '
' . '
' . htmlspecialchars(serendipity_strftime($dateformat, $entry['timestamp'])) . '

'; } } } } /* vim: set sts=4 ts=4 expandtab : */ ?>
Regards,
Bert
To bee or not to bee, that is the question
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Uh, it appears you have garbaged the file. With which editor did you save and upload the file?

It seems that the first character was cut. It needs to read "<?php" not only "?php"!

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
plofhead
Regular
Posts: 45
Joined: Fri Jun 23, 2006 9:01 am
Location: Netherlands
Contact:

Post by plofhead »

Hi Garvin,

Sorry, it seems that Wordpad made a mess of it.
Is this what you expected? It appears in the Recent Entries plugin sidebar.
SELECT DISTINCT id, title, timestamp FROM serendipity_entries WHERE isdraft = 'false' AND timestamp <= 1169142525 ORDER BY timestamp DESC LIMIT 10
Regards,
Bert
To bee or not to bee, that is the question
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Yes, that'S the intented output.

However this one says to "fetch all entries that are older than 2007-01-18 and sort them by their date descending".

I think descending is what should be used there, but maybe you could edit the php file and replace the string "timestamp DESC" with "timestamp ASC"? I always mix those up, but I think DESC should already be the one...that's too strange, it should yield the right results for your page?!

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
plofhead
Regular
Posts: 45
Joined: Fri Jun 23, 2006 9:01 am
Location: Netherlands
Contact:

Post by plofhead »

Hi Garvin,

I changed DESC into ASC but the result is exactly the same! Still starting with the oldest entry.

Regards,
Bert
To bee or not to bee, that is the question
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Hm it should at least have modified the outcome?!

Try to use the file here:

http://rafb.net/p/YCpCLU55.html

It should then set the version of your used plugin to "1.6-debug" and emit a SQL string of the used query...?

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
plofhead
Regular
Posts: 45
Joined: Fri Jun 23, 2006 9:01 am
Location: Netherlands
Contact:

Post by plofhead »

Hi,

This is the output:
Using SQL query: SELECT DISTINCT id, title, timestamp FROM serendipity_entries WHERE isdraft = 'false' AND timestamp <= 1169216918 ORDER BY timestamp ASC LIMIT 1, 12
The order is still wrong...

Regards,
Bert
To bee or not to bee, that is the question
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi.

Okay, thanks. Could you order thing back to "DESC"?

Can you tell me which entries you would expect exactly in that box? The SQL query says "show me all entries that are older than 2007-01-19, starting from entry #1 to #12.

Or wait - are you using postgresql? I believe there the LIMIT statement might be reversed or different...?

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
plofhead
Regular
Posts: 45
Joined: Fri Jun 23, 2006 9:01 am
Location: Netherlands
Contact:

Post by plofhead »

Hi Garvin,

Sorry that I put you up will so many work.

I changed to DESC, the output is now:
Using SQL query: SELECT DISTINCT id, title, timestamp FROM serendipity_entries WHERE isdraft = 'false' AND timestamp <= 1169218760 ORDER BY timestamp DESC LIMIT 1, 12
Still outputting the 12 oldest entries.

I expect the plugin to show a list of the 12 newest entries, except the entries shown on the frontpage. With version 1.0.2 this was working fine.
I should not list the entries #1 to #12, but f.i. #200 until #189.

What do you mean with postgresql?

Thanks and regards,
Bert
To bee or not to bee, that is the question
Post Reply