I have installed E-Publish 5.x-1.x-dev on Drupal 5.5. There is a error when I click Add Publication tab:
user warning: Out of range value adjusted for column 'sid' at row 1 query: INSERT INTO epublish_publication (pid, name, description, schedule, current_eid, layout_list, layout_page, sid) VALUES ('7', 'Mag', '', '', '0', '', '', '') in D:\Data\www\banoria\includes\database.mysql.inc on line 172.

It also shows "The publication "Mag" has been added.", but List Publications is empty.

Any fix available for this problem?

Thanks,
Asif

Comments

Asif99’s picture

It seems that mysql 5.0.18 does not accept '' for numerical fields. I inserted if ($edit['sid']=='') {$edit['sid']=0;} in function epublish_form_pub_submit to make it work with mysql 5.0.18:

function epublish_form_pub_submit($form_id, $edit) {
	if ($edit['sid']=='') {$edit['sid']=0;} //added to make it work with mysql 5.0.18
	if ($edit['pid'] && $edit['action'] != 'delete') {
		db_query("UPDATE {epublish_publication} SET name = '%s', description = '%s', schedule = '%s', current_eid = '%d',
		  layout_list = '%s', layout_page = '%s', sid = '%s' WHERE pid = '%d'", $edit['name'], $edit['description'],
			$edit['schedule'], $edit['current_eid'], $edit['layout_list'], $edit['layout_page'], $edit['sid'], $edit['pid']);
		drupal_set_message(t('The publication "!title" has been updated.', array('!title' => $edit['name'])));
	} else if ($edit['action'] == 'delete') {
		epublish_del_pub($edit['pid']);
	} else {
		$edit['pid'] = db_next_id('{epublish_publication}_pid');
		db_query("INSERT INTO {epublish_publication} (pid, name, description, schedule, current_eid, layout_list, layout_page, sid)
		  VALUES ('%d', '%s', '%s', '%s', '%d', '%s', '%s', '%s')", $edit['pid'], $edit['name'], $edit['description'],
			$edit['schedule'], $edit['current_eid'], $edit['layout_list'], $edit['layout_page'], $edit['sid']);
		drupal_set_message(t('The publication "!title" has been added.', array('!title' => $edit['name'])));
	}
	return 'admin/epublish';
}
Yakumo’s picture

same for mysql 5.0.51b (this is the current stable win32 build, the b does not denote beta) , thank you for the quick fix asif99.

With the current dev and beta builds this needs to go underneath the following line.

$edit = $form_state['values'];

eg :

function epublish_form_pub_submit($form, &$form_state) {
$edit = $form_state['values'];
if ($edit['sid']=='') {$edit['sid']=0;} //added to make it work with mysql 5.0.xx
	if ($edit['pid'] && $edit['action'] != 'delete') {
		db_query("UPDATE {epublish_publication} SET name = '%s', description = '%s', schedule = '%s', current_eid = '%d',layout_list = '%s', layout_page = '%s', sid = '%s' WHERE pid = '%d'", $edit['name'], $edit['description'],$edit['schedule'], $edit['current_eid'],$edit['layout_list'], $edit['layout_page'], $edit['sid'], $edit['pid']);
		drupal_set_message(t('The publication "%title" has been updated.', array('%title' => $edit['name'])));

	} else {
		
                $edit['pid'] = db_last_insert_id('epublish_publication','pid');

		db_query("INSERT INTO {epublish_publication} (pid, name, description, schedule, current_eid, layout_list, layout_page, sid)
		  VALUES ('%d', '%s', '%s', '%s', '%d', '%s', '%s', '%s')", $edit['pid'], $edit['name'], $edit['description'],$edit['schedule'], $edit['current_eid'], $edit['layout_list'], $edit['layout_page'], $edit['sid']);
		drupal_set_message(t('The publication "%title" has been added.', array('%title' => $edit['name'])));
	}
	$form_state['redirect'] = 'admin/epublish';

	$form_state['nid'] = $node->nid;

}

or it will not work as the values in $edit will be replaced by the $form_state['values'] and the fix will be undone.

gloscon’s picture

Status: Active » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.