News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Auto Purge Old Topics

Started by @rjen, October 06, 2009, 11:36:19 AM

Previous topic - Next topic

stoo23

From my tests so far, it Does NOT 'skip' the Recycle Bin, as it IS sending the Deleted posts TO our 'recycle bin' ??
 ???  :-\

stoo23

Well, I removed the selectable SMF Recycle Bin and the Auto Purge Mod works, Without causing Any cron errors.

It would appear that the existence of the Recycle bin is the cause of the cron errors.
Shame that wasn't 'fixed' / tidied up in the Code.  :(

The mod still works, just litters the Error Log with cron errors.

@rjen

Sorry you are disappointed with the mod. It is indeed related to the recycle bin. If you have a problem with the errors you are free to uninstall the mod.

If I find some time I may be able to analyze the cause further.
Running SMF 2.1 with latest TinyPortal at www.fjr-club.nl

stoo23

Oh, No, as suggested clearly above, the Mod still works and Will do what we needed it to do,.. was merely 'commenting' on the fact it generated Errors when an 'optional' (later) SMF Feature was utilized.

The cron errors in NO Way cause Any 'issues' other than requiring them to be removed from the error logs  ;)  :)

Thanks for your replies.  :D  8)
Regards,
Stewart

@rjen

#64
Well, finally had a look into the exact cause, and I can confirm that the Cron errors are related to the use of the recycle bin.

Note: when I ported this mod to 2.1.4 I made an update: the old mod would delete the topics directly, skipping the use of the recycle bin completely. I always found this a bit annoying: not being able to monitor exactly what topics were deleted so I changed it to use the recycle bin..

It is controlled by the code in the Auto_purge.php file

if(count($topics_to_purge)) {
require_once($sourcedir . '/RemoveTopic.php');

// let's do this: remove topics, don't remove post count, do NOT ignore recycling
foreach($topics_to_purge as $purge_id) {
removeTopics($topics_to_purge, false, false);
}
}

The errors can be avoided by skipping the recycle board and changing the false to truein this line...

removeTopics($topics_to_purge, false, false);

On a more technical note: the mod is using the standard SMF function "removeTopics" which in itself call the function "moveTopics" to move topics to the recycleboard.
Now this second standard SMF functions produces the error message when being called from CRON, since there is no active user in the form a a value for $user_info['id']

// Mark target board as seen, if it was already marked as seen before.
$request = $smcFunc['db_query']('', '
SELECT (COALESCE(lb.id_msg, 0) >= b.id_msg_updated) AS isSeen
FROM {db_prefix}boards AS b
LEFT JOIN {db_prefix}log_boards AS lb ON (lb.id_board = b.id_board AND lb.id_member = {int:current_member})
WHERE b.id_board = {int:id_board}',
array(
'current_member' => $user_info['id'],
'id_board' => $toBoard,
)
);

I am not sure if I can get around this problem, but perhaps one of the SMF dvelopers can give a hint to a more suitable solution?

Running SMF 2.1 with latest TinyPortal at www.fjr-club.nl

Sesquipedalian

Here's a quick workaround that you could add to your function:

global $user_info;

$user_info['id'] = !empty($user_info['id']) ? $user_info['id'] : 0;
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

@rjen

Quote from: Sesquipedalian on October 25, 2023, 05:04:32 PMHere's a quick workaround that you could add to your function:

global $user_info;

$user_info['id'] = !empty($user_info['id']) ? $user_info['id'] : 0;

I tried that and I am getting a bit further, but now we are running into more errors due to other functions assuming stuff..

QuoteGuest
 https://test.fjr-club.nl/cron.php
 /home/xxx/test/Sources/Subs-ReportedContent.php (Line 425)  Backtrace information

Type of error: Cron
Error messageSelect
2: Undefined array key "mod_cache"

QuoteGuest
 https://test.fjr-club.nl/cron.php
 /home/xxx/test/Sources/Subs-ReportedContent.php (Line 425)  Backtrace information

Type of error: Cron
Error messageSelect
2: Trying to access array offset on value of type null

QuoteGuest
 https://test.fjr-club.nl/cron.php
 /home/xxx/test/Sources/Subs-ReportedContent.php (Line 435)  Backtrace information

Type of error: Database
Error messageSelect
Databasefout: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 5

This seems to be be a bit of a domino's: one step after another falling over...
Running SMF 2.1 with latest TinyPortal at www.fjr-club.nl

Marina3

Errors:
Hook call: function "eiu_modifications" could not be called.
The callable eiu_modifications could not be called.

Link: index.php?action=admin;area=modsettings;sa=auto_purge
I use SMF 2.1.4 and php 8.2.

@rjen

That's a hook that has nothing to do with this mod
Running SMF 2.1 with latest TinyPortal at www.fjr-club.nl

@rjen

Running SMF 2.1 with latest TinyPortal at www.fjr-club.nl

Advertisement: