Fix error spam in logs due to missing cron month
This commit is contained in:
		
							parent
							
								
									8c7d785c9e
								
							
						
					
					
						commit
						aa0b7977bb
					
				| @ -122,13 +122,14 @@ class Schedule extends Model | |||||||
|      * Returns the schedule's execution crontab entry as a string. |      * Returns the schedule's execution crontab entry as a string. | ||||||
|      * |      * | ||||||
|      * @return \Carbon\CarbonImmutable |      * @return \Carbon\CarbonImmutable | ||||||
|  |      * @throws \Exception | ||||||
|      */ |      */ | ||||||
|     public function getNextRunDate() |     public function getNextRunDate() | ||||||
|     { |     { | ||||||
|         $formatted = sprintf('%s %s %s %s %s', $this->cron_minute, $this->cron_hour, $this->cron_day_of_month, $this->cron_month, $this->cron_day_of_week); |         $formatted = sprintf('%s %s %s %s %s', $this->cron_minute, $this->cron_hour, $this->cron_day_of_month, $this->cron_month, $this->cron_day_of_week); | ||||||
| 
 | 
 | ||||||
|         return CarbonImmutable::createFromTimestamp( |         return CarbonImmutable::createFromTimestamp( | ||||||
|             CronExpression::factory($formatted)->getNextRunDate()->getTimestamp() |             (new CronExpression($formatted))->getNextRunDate()->getTimestamp() | ||||||
|         ); |         ); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -0,0 +1,31 @@ | |||||||
|  | <?php | ||||||
|  | 
 | ||||||
|  | use Illuminate\Support\Facades\DB; | ||||||
|  | use Illuminate\Database\Migrations\Migration; | ||||||
|  | use Illuminate\Database\Schema\Blueprint; | ||||||
|  | use Illuminate\Support\Facades\Schema; | ||||||
|  | 
 | ||||||
|  | class ForceCronMonthFieldToHaveValueIfMissing extends Migration | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Run the migrations. | ||||||
|  |      * | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function up() | ||||||
|  |     { | ||||||
|  |         Schema::table('schedules', function (Blueprint $table) { | ||||||
|  |             DB::update("UPDATE `schedules` SET `cron_month` = '*' WHERE `cron_month` = ''"); | ||||||
|  |         }); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Reverse the migrations. | ||||||
|  |      * | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function down() | ||||||
|  |     { | ||||||
|  |         // No down function.
 | ||||||
|  |     } | ||||||
|  | } | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Dane Everitt
						Dane Everitt