From d7f603ae8bb364e613caeb1ec3ff8050286a19ae Mon Sep 17 00:00:00 2001 From: Cameron Date: Fri, 20 Feb 2015 11:03:14 -0800 Subject: [PATCH] Fixes #713, Fixes #897 - MySQL Strict Mode fixes. --- e107_admin/users.php | 5 +++++ e107_core/sql/core_sql.php | 10 +++++----- e107_handlers/admin_ui.php | 6 ++++++ e107_handlers/model_class.php | 8 ++++---- e107_plugins/faqs/admin_config.php | 2 +- 5 files changed, 21 insertions(+), 10 deletions(-) diff --git a/e107_admin/users.php b/e107_admin/users.php index 241a16a23..27c7cd7ce 100644 --- a/e107_admin/users.php +++ b/e107_admin/users.php @@ -1325,6 +1325,11 @@ class users_admin_ui extends e_admin_ui } return; } + else + { + $mes->addError(LAN_CREATED_FAILED); + $mes->addError($sql->getLastErrorText()); + } } /** diff --git a/e107_core/sql/core_sql.php b/e107_core/sql/core_sql.php index e6cb38c03..fda85c6c5 100644 --- a/e107_core/sql/core_sql.php +++ b/e107_core/sql/core_sql.php @@ -375,20 +375,20 @@ CREATE TABLE page ( page_sef varchar (250) NOT NULL default '', page_chapter int(10) unsigned NOT NULL default '0', page_metakeys varchar (250) NOT NULL default '', - page_metadscr mediumtext NOT NULL, - page_text mediumtext NOT NULL, + page_metadscr mediumtext, + page_text mediumtext, page_author int(10) unsigned NOT NULL default '0', page_datestamp int(10) unsigned NOT NULL default '0', page_rating_flag tinyint(1) unsigned NOT NULL default '0', page_comment_flag tinyint(1) unsigned NOT NULL default '0', page_password varchar(50) NOT NULL default '', page_class varchar(250) NOT NULL default '0', - page_ip_restrict text NOT NULL, + page_ip_restrict text, page_template varchar(50) NOT NULL default '', page_order int(4) unsigned NOT NULL default '9999', menu_name varchar(50) NOT NULL default '', menu_title varchar(250) NOT NULL default '', - menu_text mediumtext NOT NULL, + menu_text mediumtext, menu_image varchar(250) NOT NULL default '', menu_icon varchar(250) NOT NULL default '', menu_template varchar(50) NOT NULL default '', @@ -546,7 +546,7 @@ CREATE TABLE user ( user_perms text NOT NULL, user_realm text NOT NULL, user_pwchange int(10) unsigned NOT NULL default '0', - user_xup text NOT NULL, + user_xup text, PRIMARY KEY (user_id), UNIQUE KEY user_name (user_name), UNIQUE KEY user_loginname (user_loginname), diff --git a/e107_handlers/admin_ui.php b/e107_handlers/admin_ui.php index 4a4066611..bc96462f5 100644 --- a/e107_handlers/admin_ui.php +++ b/e107_handlers/admin_ui.php @@ -5176,6 +5176,12 @@ class e_admin_ui extends e_admin_controller_ui $this->dataFields = array(); foreach ($this->fields as $key => $att) { + if($key == $this->pid && empty($att['data'])) // Set integer as default for primary ID when not specified. MySQL Strict Fix. + { + $this->dataFields[$key] = 'int'; + continue; + } + if($att['type'] == 'comma' && (!vartrue($att['data']) || !vartrue($att['rule']))) { $att['data'] = 'set'; diff --git a/e107_handlers/model_class.php b/e107_handlers/model_class.php index ada56b7db..f4a8ec811 100644 --- a/e107_handlers/model_class.php +++ b/e107_handlers/model_class.php @@ -2552,17 +2552,17 @@ class e_front_model extends e_model $id = $this->getId(); $qry['data'][$this->getFieldIdName()] = $id; + //XXX This check is done in _setModel() of admin-ui. NULL below will break MySQL strict. + // Allow admin config to specify the best data type. + /* if($action == 'create' && !$id) $qry['_FIELD_TYPES'][$this->getFieldIdName()] = 'NULL'; elseif(is_numeric($id)) $qry['_FIELD_TYPES'][$this->getFieldIdName()] = 'integer'; else $qry['_FIELD_TYPES'][$this->getFieldIdName()] = 'string'; + */ foreach ($this->_data_fields as $key => $type) { - if($key == $this->getFieldIdName()) - { - continue; - } if(!isset($qry['_FIELD_TYPES'][$key])) { $qry['_FIELD_TYPES'][$key] = $type; //_FIELD_TYPES much more optional now... diff --git a/e107_plugins/faqs/admin_config.php b/e107_plugins/faqs/admin_config.php index bf79af7f9..54353cf10 100644 --- a/e107_plugins/faqs/admin_config.php +++ b/e107_plugins/faqs/admin_config.php @@ -182,7 +182,7 @@ class faq_main_ui extends e_admin_ui //TODO - finish 'user' type, set 'data' to all editable fields, set 'noedit' for all non-editable fields protected $fields = array( 'checkboxes' => array('title'=> '', 'type' => null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center', 'class'=>'center'), - 'faq_id' => array('title'=> LAN_ID, 'tab' => 0, 'type' => 'int', 'width' =>'5%', 'forced'=> TRUE), + 'faq_id' => array('title'=> LAN_ID, 'tab' => 0, 'type' => null, 'width' =>'5%', 'forced'=> TRUE), 'faq_question' => array('title'=> LANA_FAQ_QUESTION, 'tab' => 0, 'type' => 'text', 'width' => 'auto', 'thclass' => 'left first', 'required'=>TRUE, 'readParms'=>'editable=1', 'writeParms'=>'size=block-level'), 'faq_answer' => array('title'=> LANA_FAQ_ANSWER, 'tab' => 0, 'type' => 'bbarea', 'width' => '30%', 'readParms' => 'expand=1&truncate=50&bb=1'), 'faq_parent' => array('title'=> LAN_CATEGORY, 'tab' => 0, 'type' => 'dropdown', 'data'=> 'int', 'inline'=>true,'width' => '10%', 'filter'=>TRUE, 'batch'=>TRUE),