Be sure to checkout our newest add-on, Speedy — Advanced Caching for ExpressionEngine.

Compatibility updates:

  • Publisher is EE5 compatible, but it does not currently support the Fluid field (it's in the works).

Ticket: Changing text field type from allowed content of ‘integer’ to ‘all’ causes SQL error upon article save

Status Resolved
Add-on / Version Publisher 3.1.1
Severity
EE Version 5.3.0

Bruce Sabalaskey

Jan 08, 2020

I have a text field attached to an article, which is intended to indicate a paragraph number. That text field was originally defined as accepting integer inputs. However, saving said field with an empty string converts it to 0, which is not desired because of other side effects built into template processing. Hence the EE field was changed from allowing only integers to allowing all text. However, then saving an article with an empty string in said field results in this SQL error. So Publisher is not catching that the allowed content for that field has been updated.

Exception Caught
SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'field_id_199' at row 1:
UPDATE `exp_publisher_data_field_199` SET `entry_id` = 206319, `lang_id` = 1, `status` = 'draft', `is_fluid` = 0, `field_id_199` = '' WHERE `entry_id` = 206319 AND `lang_id` = 1 AND `status` = 'draft' AND `is_fluid` = 0
ee/legacy/database/drivers/mysqli/mysqli_connection.php:117

Stack Trace: Please include when reporting this error
#0 ee/legacy/database/drivers/mysqli/mysqli_driver.php(112): CI_DB_mysqli_connection->query('UPDATE `exp_pub…')
#1 ee/legacy/database/DB_driver.php(270): CI_DB_mysqli_driver->_execute('UPDATE `exp_pub…')
#2 ee/legacy/database/DB_driver.php(180): CI_DB_driver->simple_query('UPDATE `exp_pub…')
#3 ee/legacy/database/DB_active_rec.php(1477): CI_DB_driver->query('UPDATE `exp_pub…')
#4 user/addons/publisher/Model/EntryTranslation.php(156): CI_DB_active_record->update('publisher_data_…', Array, Array)
#5 user/addons/publisher/Model/EntryTranslation.php(103): BoldMinded\Publisher\Model\EntryTranslation->updateCustomFields(Array, Array)
#6 user/addons/publisher/Service/Entry/Entry.php(315): BoldMinded\Publisher\Model\EntryTranslation->save()
#7 user/addons/publisher/ext.publisher.php(541): BoldMinded\Publisher\Service\Entry\Entry->save(Object(EllisLab\ExpressionEngine\Model\Channel\ChannelEntry), Array)
#8 ee/legacy/libraries/Extensions.php(222): Publisher_ext->after_channel_entry_save(Object(EllisLab\ExpressionEngine\Model\Channel\ChannelEntry), Array)
#9 ee/legacy/libraries/Extensions.php(117): EE_Extensions->call_class('Publisher_ext', 'after_channel_e…', Array, Array)
#10 [internal function]: EE_Extensions->call('after_channel_e…', Object(EllisLab\ExpressionEngine\Model\Channel\ChannelEntry), Array)
#11 ee/EllisLab/ExpressionEngine/Service/Model/Model.php(635): call_user_func_array(Array, Array)
#12 [internal function]: EllisLab\ExpressionEngine\Service\Model\Model->EllisLab\ExpressionEngine\Service\Model\{closure}('after_channel_e…', Object(EllisLab\ExpressionEngine\Model\Channel\ChannelEntry), Array)
#13 ee/EllisLab/ExpressionEngine/Service/Model/Model.php(608): call_user_func_array(Object(Closure), Array)
#14 [internal function]: EllisLab\ExpressionEngine\Service\Model\Model->EllisLab\ExpressionEngine\Service\Model\{closure}()
#15 ee/EllisLab/ExpressionEngine/Service/Event/Emitter.php(141): call_user_func_array(Object(Closure), Array)
#16 [internal function]: EllisLab\ExpressionEngine\Service\Event\Emitter->emit('afterSave')
#17 ee/EllisLab/ExpressionEngine/Library/Data/Entity.php(654): call_user_func_array(Array, Array)
#18 [internal function]: EllisLab\ExpressionEngine\Library\Data\Entity->emit('afterSave')
#19 ee/EllisLab/ExpressionEngine/Service/Model/Model.php(828): call_user_func_array('parent::emit', Array)
#20 ee/EllisLab/ExpressionEngine/Service/Model/Query/Update.php(51): EllisLab\ExpressionEngine\Service\Model\Model->emit('afterSave')
#21 ee/EllisLab/ExpressionEngine/Service/Model/DataStore.php(282): EllisLab\ExpressionEngine\Service\Model\Query\Update->run()
#22 ee/EllisLab/ExpressionEngine/Service/Model/DataStore.php(248): EllisLab\ExpressionEngine\Service\Model\DataStore->runQuery('Update', Object(EllisLab\ExpressionEngine\Service\Model\Query\Builder))
#23 ee/EllisLab/ExpressionEngine/Service/Model/Query/Builder.php(71): EllisLab\ExpressionEngine\Service\Model\DataStore->updateQuery(Object(EllisLab\ExpressionEngine\Service\Model\Query\Builder))
#24 ee/EllisLab/ExpressionEngine/Service/Model/Model.php(361): EllisLab\ExpressionEngine\Service\Model\Query\Builder->update()
#25 ee/EllisLab/ExpressionEngine/Model/Content/ContentModel.php(225): EllisLab\ExpressionEngine\Service\Model\Model->save()
#26 ee/EllisLab/ExpressionEngine/Controller/Publish/AbstractPublish.php(376): EllisLab\ExpressionEngine\Model\Content\ContentModel->save()
#27 ee/EllisLab/ExpressionEngine/Controller/Publish/Edit.php(527): EllisLab\ExpressionEngine\Controller\Publish\AbstractPublish->saveEntryAndRedirect(Object(EllisLab\ExpressionEngine\Model\Channel\ChannelEntry))
#28 [internal function]: EllisLab\ExpressionEngine\Controller\Publish\Edit->entry('206319')
#29 ee/EllisLab/ExpressionEngine/Core/Core.php(241): call_user_func_array(Array, Array)
#30 ee/EllisLab/ExpressionEngine/Core/Core.php(110): EllisLab\ExpressionEngine\Core\Core->runController(Array)
#31 ee/EllisLab/ExpressionEngine/Boot/boot.php(151): EllisLab\ExpressionEngine\Core\Core->run(Object(EllisLab\ExpressionEngine\Core\Request))
#32 public_html/lsncp.php(153): require_once('...')
#32 public_html/lsncp.php(153): require_once('...')
#1

BoldMinded (Brian)

Jan 09, 2020

Can you check the database table exp_publisher_data_field_199 and tell me what the column Type is set to for the field_id_199 column? Is it still INT or did it change to Text?

#2

BoldMinded (Brian)

Jan 09, 2020

I found the issue. In FieldSchema.php, line 302, change it to this:

if (array_key_exists($fieldName, $tableColumns)) {

It used to be $tableName, but it should be $fieldName. I can send a new build later, but I believe this will fix the issue for you. You might have to re-save the field to get the table to update properly after the code change.

#3

Bruce Sabalaskey

Jan 09, 2020

Yes, the column remained an INT. I will try your fix and let you know.

mysql> explain exp_publisher_data_field_199;
+--------------+------------------+------+-----+---------+----------------+
| Field        | Type             | Null | Key | Default | Extra          |
+--------------+------------------+------+-----+---------+----------------+
| id           | int(10) unsigned | NO   | PRI | NULL    | auto_increment |
| entry_id     | int(2)           | YES  | MUL | NULL    |                |
| field_id_199 | int(11)          | YES  |     | NULL    |                |
| lang_id      | int(4)           | YES  |     | 1       |                |
| status       | varchar(24)      | YES  |     | open    |                |
| is_fluid     | int(1)           | YES  |     | 0       |                |
+--------------+------------------+------+-----+---------+----------------+
#4

Bruce Sabalaskey

Jan 09, 2020

Thank you, that did the trick. The column is correctly changed to text. There is *no* need for pushing a release just for that, rather wait until your next one, as I just updated my code for now. Yes, I did have to re-save the field, piece of cake.

Login to reply

Contact

For add-on support, please use the Support section. General inquries and pre-sale questions can be sent to support@boldminded.com.