MyBB Community Forums

Full Version: mktime() expects paramete 1 to be Long, String given
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm using the core function fetch_next_run() for when inserting a task in my plugin and whenever it's ran, the warning below is thrown:

"mktime() expects paramete 1 to be Long, String given"

I've checked the core source of MyBB and am doing exactly as is done in the core, so I assume the above is also thrown there. Here's my code:

$taskExists = $db->simple_select('tasks', 'tid', 'file = \'myalerts\'', array('limit' => '1'));
if ($db->num_rows($taskExists) == 0) {
	require_once MYBB_ROOT.'/inc/functions_task.php';

	$myTask = array(
		'title'               => $lang->myalerts_task_title,
		'file'                => 'myalerts',
		'description'   => $lang->myalerts_task_description,
		'minute'          => '0',
		'hour'              => '1',
		'day'               => '*',
		'weekday'      => '1',
		'month'          => '*',
		'nextrun'        => TIME_NOW + 3600,
		'lastrun'         => 0,
		'enabled'       => 1,
		'logging'        => 1,
		'locked'         => 0,
	);

	$task_id = $db->insert_query('tasks', $myTask);
	$theTask = $db->fetch_array($db->simple_select('tasks', '*', 'tid = '.(int) $task_id, 1));
	$nextrun = fetch_next_run($myTask);
	$db->update_query('tasks', 'nextrun = '.$nextrun, 'tid = '.(int) $task_id);
	$plugins->run_hooks('admin_tools_tasks_add_commit');
	$cache->update_tasks();
}
Doesn't work if you change:
        'minute'          => '0',
        'hour'              => '1',
        'day'               => '*',
        'weekday'      => '1',

To:
        'minute'          => 0,
        'hour'              => 1,
        'day'               => '*',
        'weekday'      => 0,

?

I come to the same issue once while writing a plugin, just can't remember the solution I applied, if any (maybe I just dropped the task idea).
Thanks Omar, I'll give it a try and see if it helps.