Jump to content

Recommended Posts

Posted

Hey guys,

I have got a problem with the close bids after expire function. The CRON job removes the bid so it`s no longer displayed under the recentbids but as i have disable SCHED on BIDS active it doesn`t show up in my schedules again after the cron job has removed the bid. I have to delete the flight completely from the schedules and add it as a new flight in order to make it show up again. So in the maintenance.php i just find this:

if(Config::Get('CLOSE_BIDS_AFTER_EXPIRE') === true)
{
SchedulesData::deleteExpiredBids();
CronData::set_lastupdate('check_expired_bids');
}

but where can i find the code for what actually is happening then so that i can take a look and find out what`s going wrong there.

ok i found it in SchedulesData

public static function deleteExpiredBids()
{ 
 $cache_time = Config::Get('BID_EXPIRE_TIME');
 if($cache_time == '')
 {
  return;
 }

 $sql = 'DELETE FROM '.TABLE_PREFIX."bids
   WHERE `dateadded` + INTERVAL {$cache_time} HOUR < NOW()";

 DB::query($sql);

}

if i get it right it deletes the bid from the _bids table..... but does it also update the bidid column in the schedules table to 0 again?!? i think that is the reason why it doesn`t show up...is that possible?

  • 1 month later...
Posted

Ok i know now for sure that the problem is that the bidid in the schedules table isn't updated to 0.

Could someone be so kind to show me what i need to add to the function in my first post to not only delete the bids from the bids table but also Update the bidid column for that flight to 0 in the schedules table?

kind regards

Manuel

  • Moderators
Posted

Manuel,

I found the bug. ;) (smacks bug with hand!)

Head to SchedulesData.class.php and go to line 861.

Look for the function...

public static function deleteExpiredBids()

Inside of the function, replace the whole function with this... my modification.

public static function deleteExpiredBids() {

    $cache_time = Config::Get('BID_EXPIRE_TIME');
    if ($cache_time == '') {
	    return;
    }

    /* Make sure the schedule bidids */
    $sql = 'SELECT * FROM ' . TABLE_PREFIX . "bids
               WHERE `dateadded` + INTERVAL {$cache_time} HOUR < NOW()";

    $results = DB::get_results($sql);
    if (count($results) > 0) {
	    foreach ($results as $row) {
		    $sql = 'UPDATE ' . TABLE_PREFIX . "schedules
                       SET `bidid`=0 WHERE `id`={$row->routeid}";

		    DB::query($sql);
	    }
    }

And that issue should not be a pain again. ;)

  • Like 1
Posted

Wow once again thanks a lot Kyle. That issue really was a pain. Especially in the beginning when I didn't know why my flights don't reappear in the schedules hehe

Posted

hm i pasted it exactly like in your post now but it gives me

Warning: Invalid argument supplied for foreach() in /var/html/eco1005016/html/core/common/SchedulesData.class.php on line 913

when i run maintenance.php

  • 2 months later...
  • 1 month later...
Posted (edited)

I'm getting

Parse error: syntax error, unexpected T_PUBLIC in /home/taromvir/public_html/core/common/SchedulesData.class.php on line 886

line 886 is

public static function removeBid($bidid)

- the next function.

Any solution!?

LE

there was a missing closing bracket }

LE2

It's not working.

I've also created a cronjob to run "maintenance" every hour and still no joy. Anyone?!

Edited by loplo
  • 3 months later...
  • 3 years later...
Posted

Easy solution:

public static function deleteExpiredBids()

{

$cache_time = Config::Get('BID_EXPIRE_TIME');

if ($cache_time == '') {

return;

}

/* Make sure the schedule bidids */

$sql = 'SELECT * FROM ' . TABLE_PREFIX . "bids

WHERE `dateadded` + INTERVAL {$cache_time} HOUR < NOW()";

$results = DB::get_results($sql);

if (count($results) > 0) {

foreach ($results as $row) {

$sql = 'UPDATE ' . TABLE_PREFIX . "schedules

SET `bidid`=0 WHERE `id`={$row->routeid}";

DB::query($sql);

}

}

$sql = 'DELETE FROM '.TABLE_PREFIX."bids

WHERE `dateadded` + INTERVAL {$cache_time} HOUR < NOW()";

DB::query($sql);

}

  • 8 months later...
Posted
On 25/08/2012 at 0:11 PM, Kyle said:

Manuel,

I found the bug. ;) (smacks bug with hand!)

Head to SchedulesData.class.php and go to line 861.

Look for the function...

 


public static function deleteExpiredBids()
 

 

Inside of the function, replace the whole function with this... my modification.

 


public static function deleteExpiredBids() {

    $cache_time = Config::Get('BID_EXPIRE_TIME');
    if ($cache_time == '') {
	    return;
    }

    /* Make sure the schedule bidids */
    $sql = 'SELECT * FROM ' . TABLE_PREFIX . "bids
               WHERE `dateadded` + INTERVAL {$cache_time} HOUR < NOW()";

    $results = DB::get_results($sql);
    if (count($results) > 0) {
	    foreach ($results as $row) {
		    $sql = 'UPDATE ' . TABLE_PREFIX . "schedules
                       SET `bidid`=0 WHERE `id`={$row->routeid}";

		    DB::query($sql);
	    }
    }
 

 

And that issue should not be a pain again. ;)

 

 

I tried Kyle's suggestion above and still was getting an error.

So I made some changes on it and now it's working fine. Finally I don't need an extra script on my server just to remove expired bids... 

Thanks Kyle for the great help! :D

 

public static function deleteExpiredBids(){
	$cache_time = Config::Get('BID_EXPIRE_TIME');
	if($cache_time == ''){ return; }
	$selectbids = 'SELECT * FROM ' . TABLE_PREFIX . "bids WHERE `dateadded` + INTERVAL {$cache_time} HOUR < NOW()";
      $results = DB::get_results($selectbids);
      $deletebids = 'DELETE FROM '.TABLE_PREFIX."bids WHERE `dateadded` + INTERVAL {$cache_time} HOUR < NOW()";
	if(count($results) > 0){
		foreach ($results as $row){
			DB::query($deletebids);
			$updateschedules = 'UPDATE ' . TABLE_PREFIX . "schedules SET `bidid`=0 WHERE `id`={$row->routeid}";
			DB::query($updateschedules);
		}
	}
}

 

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...