Subject: Busted Older Stories Block

Posted on: 05/03/02 10:18pm
By: squatty

For quite some time now I've been trying to get the Older Stories Block to work on my Geeklog install. My first attempt was on version 1.3, then 1.3.1, and now on 1.3.3. All attempts have failed!

My problems have all centered on the COM_olderstuff function in lib-common.php.

Thus far I've narrowed it down to two issues:

The select statement returns no rows. For some reason all of my stories have a draft_flag = 0 and not = 1. The second problem is in the DB_delete and DB_save function calls. The SQL generated results in an error. Specifically the title value appears in double quotes, “Older Stories” and not single quotes ‘Older Stories’. This breaks the SQL statements. To fix the problem I resorted to the following hack:

//DB_delete($_TABLES['blocks'],'title',"''");
//DB_save($_TABLES['blocks'],'title,blockorder,content',"'','','$string'");
DB_delete('blocks','title','Older Stories');
DB_save('blocks','title,blockorder,content',"'Older Stories','7','$string'");

Has anyone run across similar issues? If so how did you correct the problem?

Thanks,
Danny


Well...

Posted on: 06/03/02 09:47am
By: Tony

first: draft_flag = 0 means the story is not a draft thus it should be pulled. This is contrary to your first point. second: I have a stock 1.3.3 install on iowaoutdoors.org and the older stories block works without modification. What OS/Web Server/ and version of MySQL are you running? ----- The reason people blame things on previous generations is that there's only one other choice.

Well...

Posted on: 06/03/02 11:17am
By: squatty

Tony,

The lib-common.php code included in the 1.3.3 distribution has the following SQL query in the COM_olderstuff function:

$result = DB_query("SELECT sid,title,comments,unix_timestamp(date) AS day FROM "
. $_TABLES['stories'] . " WHERE draft_flag = 1 ORDER BY date desc LIMIT , "); $nrows = DB_numRows($result);

As I stated in the first issue, all of my stories have a draft_flag = 0. You also pointed out that this is correct. Why is the SQL looking for draft_flag = 0?

As for my install, I am running Geeklog 1.3.3 on RedHat 7.2 with Apache 1.3.23 and PHP 4.1.1.

Thanks,
Danny


Well...

Posted on: 06/03/02 01:11pm
By: Tony

The code for the block sux (legacy 1.1 code). It should not delete the block at all. Instead it should do a UPDATE statement. This could one of the reasons why the bid in the block table is so fubar'd. Let me hack at it a bit and I'll post the code fix here. ----- The reason people blame things on previous generations is that there's only one other choice.

How do you create the block?

Posted on: 06/03/02 01:25pm
By: Anonymous

Do you set it up as a PHP Block? COM_olderstuff doesn't return anything, so I don't think that will work. Is there a simple step-by-step procedure for turning Older Stories on?

The fix...

Posted on: 06/03/02 01:41pm
By: Tony

Replace your COM_olderstuff() with this.

-----
The reason people blame things on previous generations is that there's only one other choice.


Well...

Posted on: 06/03/02 01:51pm
By: squatty

Sounds good. Thanks for your help on this one.

How do you create the block?

Posted on: 06/03/02 02:01pm
By: squatty

You don't. All you do is set the following value in your config.php file to 1:

$_CONF['olderstuff'] = 1; //1 = on 0= off

The block is created for you. The code for the block is in lib-common.php.


The fix...

Posted on: 06/03/02 02:17pm
By: Anonymous

Hmm. I just applied this fix, and it made no difference. olderstuff is set to 1 in my config.php. I still don't see the block on my site.

The fix...

Posted on: 06/03/02 02:23pm
By: Tony

Well, another detail of this is you will need to edit an article and save it without making the changes. This will force the COM_olderstuff block to run. Also, make sure you didn't deselect the block in you Display Preferences. Finally, ensure you have a block in your system with the name 'older_stories'. As long as you have all that it should work. ----- The reason people blame things on previous generations is that there's only one other choice.

The fix...

Posted on: 06/03/02 02:26pm
By: Anonymous

Ah. Okay. I don't have a block named "older_stories" in my system. If I add it, what do I add for content? It won't accept a block without content.

The fix...

Posted on: 06/03/02 02:29pm
By: Anonymous

Nevermind. I got it working. Thanks!

The fix...

Posted on: 06/03/02 02:32pm
By: squatty

Did you just add a normal block named Older Stories and then hit your site? I don't seem to be getting updates even after re-saving a new story. For example, delete the content of your Older Stories block (after it has been created). Then hit your site. The bock should re-create itself. Right?

The fix...

Posted on: 06/03/02 02:46pm
By: Anonymous

Well, I just put some bogus content in there. Specifically, I created a Normal Block, named it older_stories and put "Nothing to see here" in the content field. Then I edited an article and re-saved it. Hey, presto! The block started working. Sort of. I just noticed that it only contains some of my older articles. Specifically starting with Monday and going backwards. This would make sense if it decides an "old" story is at least 48 hours old, but I can't see anything in COM_olderstuff to back that claim up.

No...

Posted on: 07/03/02 07:16am
By: Tony

No, only when you save a story does the older_stories block get generated (which makes sense). This prevents us from executing SQL for every page request when it is only needed when stories are added, changed or deleted. ----- The reason people blame things on previous generations is that there's only one other choice.

Geeklog - Forum
https://www.geeklog.net/forum/viewtopic.php?showtopic=10209