Recent Topics

1 Jun 02, 2010 03:04    

My b2evolution Version: 3.3.3

After setting up my cron job for session & hit pruning and running it successfully for a month, I find I literally have thousands of session entries from cron hitting the cron_exec.php file to see if there is anything to do.

Now, I know I could slow down how often cron checks this file for pending jobs, but I was wondering if there was an easy way (easy meaning one or two files to edit) to have the session and hit logging routines ignore the direct hits from my local cron daemon.

Where would I look for the code that writes the session and hit info to the database?

2 Jun 02, 2010 03:48

How did you set up the cron job? You should use the command like this

/usr/bin/php /home/user/public_html/blogs/cron/cron_exec.php > /dev/null 2>&1

3 Jun 02, 2010 04:31

Yep. The path is slightly different of, course, but that is exactly how my cron job is set up. But b2evo is adding a session entry to the b2evo session table every time cron wakes up and checks cron_exec.php. It's no big deal, but it's rather unnecessary.

Plus, the requested URI that gets stored isn't really relevant to web traffic reports. With a cron job like you suggested (and I've implemented)... the Requested URI that gets stored in the database would be:

Are you saying that redirecting the job's output to /dev/null 2>&1 is supposed to prevent b2evo from logging those hits and sessions?

4 Jun 02, 2010 06:13

Are you saying that redirecting the job's output to /dev/null 2>&1 is supposed to prevent b2evo from logging those hits and sessions?

I don't think so. Actually this hit shouldn't be logged at all.

Let me check how it works...

5 Jun 02, 2010 06:21

Ok, add this line to cron_exec.php, it should prevent logging.

require_once $inc_path .'';

$Hit->logged = true;

6 Jun 02, 2010 13:14

That stopped it from logging anything in the hit table... so thanks for that! But it's still assigning it a new session ID and logging it every time. I took a chance and tried:

$Session->logged = true;

I got absolutely no love with that bit of code. :-/

Any ideas?

7 Jun 02, 2010 15:10

if( ! $is_cli )
{ // This is a web request:
	echo '<p><a href="cron_exec.php">Refresh Now!</a></p>';
	echo '<p>This page should refresh automatically in 15 seconds...</p>';
	echo '<!-- This is invalid HTML but it is SOOOOOO helpful! (Delay will be triggered when we reach that point -->';
	echo '<meta http-equiv="Refresh" content="15" />';


$Session->_session_needs_save = false;
$Hit->logged = true;


8 Jun 02, 2010 16:52

I had high hopes, but...

$Session->_session_needs_save = false;

seemed to have no effect - still creating and logging new session ids every time cron accesses the file.

Perhaps it has something to do with the following code in

 * The Session class.
 * The Session object.
 * It has to be instantiated before the "SessionLoaded" hook.
 * @global Session
 * @todo dh> This needs the same "SET NAMES" MySQL-setup as with Session::dbsave() - see the "TODO" with unserialize() in Session::Session()
 * @todo dh> makes no sense in CLI mode (no cookie); Add isset() checks to calls on the $Session object, e.g. below?
 *       fp> We might want to use a special session for CLI. And for cron jobs through http as well.
$Session = & new Session(); // IF this can't pull asesion from the DB it will always INSERT a new one!

9 Jun 02, 2010 16:59

What happens if you add :


Just after the needs saving stuff?


10 Jun 02, 2010 17:27

No love there either.
- plus it sounded a little scary 8|

EDIT: and apparently, dbdelete() is an undefined method. I wondered when I didn't see it in the _session.class.php file. ;)

Form is loading...