Be sure to checkout our newest add-on Reading Time Pro!

EE4 compatibility updates:

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

Ticket: Errors when saving entry

Status Resolved
Add-on / Version Publisher Lite 3.1.2
Severity
EE Version 5.3.0
Images

Hop Studios

Feb 07, 2020

Hey Brian,

Got a weird one. I downloaded the latest version of Publisher Lite and had it working on my local copy. But when I push to the staging server, I get the following errors when saving as draft/published:

Undefined property: stdClass::$column_name
user/addons/publisher/Service/ChannelField.php, line 225

Severity: E_NOTICE

And the trace

SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'field_id_38' at row 1:
UPDATE `exp_channel_data` SET `field_id_38` = '' WHERE `entry_id` = 6685
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_cha…')
#1 ee/legacy/database/DB_driver.php(270): CI_DB_mysqli_driver->_execute('UPDATE `exp_cha…')
#2 ee/legacy/database/DB_driver.php(180): CI_DB_driver->simple_query('UPDATE `exp_cha…')
#3 ee/legacy/database/DB_active_rec.php(1477): CI_DB_driver->query('UPDATE `exp_cha…')
#4 user/addons/publisher/Service/Entry/Entry.php(559): CI_DB_active_record->update('exp_channel_dat…', Array)
#5 user/addons/publisher/ext.publisher.php(565): BoldMinded\Publisher\Service\Entry\Entry->cleanup(Object(EllisLab\ExpressionEngine\Model\Channel\ChannelEntry), Array)
#6 ee/legacy/libraries/Extensions.php(222): Publisher_ext->after_channel_entry_update(Object(EllisLab\ExpressionEngine\Model\Channel\ChannelEntry), Array, Array)
#7 ee/legacy/libraries/Extensions.php(117): EE_Extensions->call_class('Publisher_ext', 'after_channel_e…', Array, Array)
#8 [internal function]: EE_Extensions->call('after_channel_e…', Object(EllisLab\ExpressionEngine\Model\Channel\ChannelEntry), Array, Array)
#9 ee/EllisLab/ExpressionEngine/Service/Model/Model.php(635): call_user_func_array(Array, Array)
#10 [internal function]: EllisLab\ExpressionEngine\Service\Model\Model->EllisLab\ExpressionEngine\Service\Model\{closure}('after_channel_e…', Object(EllisLab\ExpressionEngine\Model\Channel\ChannelEntry), Array, Array)
#11 ee/EllisLab/ExpressionEngine/Service/Model/Model.php(608): call_user_func_array(Object(Closure), Array)
#12 [internal function]: EllisLab\ExpressionEngine\Service\Model\Model->EllisLab\ExpressionEngine\Service\Model\{closure}(Array)
#13 ee/EllisLab/ExpressionEngine/Service/Event/Emitter.php(141): call_user_func_array(Object(Closure), Array)
#14 [internal function]: EllisLab\ExpressionEngine\Service\Event\Emitter->emit('afterUpdate', Array)
#15 ee/EllisLab/ExpressionEngine/Library/Data/Entity.php(654): call_user_func_array(Array, Array)
#16 [internal function]: EllisLab\ExpressionEngine\Library\Data\Entity->emit('afterUpdate', Array)
#17 ee/EllisLab/ExpressionEngine/Service/Model/Model.php(828): call_user_func_array('parent::emit', Array)
#18 ee/EllisLab/ExpressionEngine/Service/Model/Query/Update.php(52): EllisLab\ExpressionEngine\Service\Model\Model->emit('afterUpdate', Array)
#19 ee/EllisLab/ExpressionEngine/Service/Model/DataStore.php(282): EllisLab\ExpressionEngine\Service\Model\Query\Update->run()
#20 ee/EllisLab/ExpressionEngine/Service/Model/DataStore.php(248): EllisLab\ExpressionEngine\Service\Model\DataStore->runQuery('Update', Object(EllisLab\ExpressionEngine\Service\Model\Query\Builder))
#21 ee/EllisLab/ExpressionEngine/Service/Model/Query/Builder.php(71): EllisLab\ExpressionEngine\Service\Model\DataStore->updateQuery(Object(EllisLab\ExpressionEngine\Service\Model\Query\Builder))
#22 ee/EllisLab/ExpressionEngine/Service/Model/Model.php(361): EllisLab\ExpressionEngine\Service\Model\Query\Builder->update()
#23 ee/EllisLab/ExpressionEngine/Model/Content/ContentModel.php(225): EllisLab\ExpressionEngine\Service\Model\Model->save()
#24 ee/EllisLab/ExpressionEngine/Controller/Publish/AbstractPublish.php(376): EllisLab\ExpressionEngine\Model\Content\ContentModel->save()
#25 ee/EllisLab/ExpressionEngine/Controller/Publish/Edit.php(527): EllisLab\ExpressionEngine\Controller\Publish\AbstractPublish->saveEntryAndRedirect(Object(EllisLab\ExpressionEngine\Model\Channel\ChannelEntry))
#26 [internal function]: EllisLab\ExpressionEngine\Controller\Publish\Edit->entry('6685')
#27 ee/EllisLab/ExpressionEngine/Core/Core.php(241): call_user_func_array(Array, Array)
#28 ee/EllisLab/ExpressionEngine/Core/Core.php(110): EllisLab\ExpressionEngine\Core\Core->runController(Array)
#29 ee/EllisLab/ExpressionEngine/Boot/boot.php(151): EllisLab\ExpressionEngine\Core\Core->run(Object(EllisLab\ExpressionEngine\Core\Request))

The only difference that I can think of is the local copy is running mysql 5.7 and the staging/live server is running mysql 8. Any idea?

Gilbert

#1

BoldMinded (Brian)

Feb 07, 2020

My first thought is that I haven’t tested anything in MySQL 8. It probably has something to do with strict_mode. What is the column set to in the database? Text or integer? Try re-saving the custom field to make sure the column type is correct. There was a bug that 3.1.2 fixed where if you changed a custom field from text to integer or integer to text it didn’t update the database correctly.

This is a last resort too, just turning off strict mode.

# add to file /etc/mysql/mysql.conf.d/mysqld.cnf
[mysqld]
sql_mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

Side note, I don’t know your scenario, but it seems risky to run local or dev in 5.7 then production in 8. That’s quite a leap.

#2

Hop Studios

Feb 07, 2020

Hey Brian,

I tried the sql_mode setting before message you and it’s not that. I did some more debugging and got it to work. For your reference, these are the files that I changed:
Service/Entry/Entry.php @line 529. I added date as one of the option as date fields are saved as int(10) for my EE installation // Don’t know if it’s the default for others

$intTypes = ['int', 'tinyint', 'smallint', 'mediumint', 'bigint', 'float', 'date'];

Service/ChannelField.php @line 224. This is the real cause for my case, when getting the schema, the property in the stdClass is uppercase… so I needed to change the code to

foreach ($schemaQuery->result() as $row) {
    if (isset($row->COLUMN_NAME) && substr($row->COLUMN_NAME, 0, 9) === 'field_id_') {
        $columns[$row->COLUMN_NAME] = $row->DATA_TYPE;
    }
}

The isset is probably not needed? What do you think? I’m going to read more on this but do you have an idea on how I can prevent the error without altering your code manually?

#3

Hop Studios

Feb 07, 2020

Or maybe you can use result_array() and

$row = array_change_key_case($row, CASE_LOWER);

Just some thoughts.

#4

BoldMinded (Brian)

Feb 07, 2020

So the lower cased version works in MySQL 5.7 but it needed to be uppercase in 8? Just wondering why this code has been fine up until now. MySQL 8 seems to be the difference.

#5

Hop Studios

Feb 07, 2020

Not too sure… might be just how the schema info is stored. However, I didn’t make any custom changes to the mysql installation.
What do you think about my suggestion to use result_array to make sure all installation will function correctly?

- Gilbert

#6

BoldMinded (Brian)

Feb 09, 2020

I’ll have to setup a MySQL 8 instance to test these queries, it just doesn’t make any sense that you’re getting $row->COLUMN_NAME when it’s been working as $row->column_name for well over a year now. You’re the first customer I know of using MySQL 8 too. Can you verify that in your local env that is using MySQL 5.x that the code works as intended, e.g. $row->column_name is in fact set and lower case without any modification to the code? Then verify in version 8 that it is upper cased? If there is a difference then this is the code change that I could consider.

foreach ($schemaQuery->result_array() as $row) {
                $row = array_change_key_case($row, CASE_LOWER);

                if (substr($row['column_name'], 0, 9) === 'field_id_') {
                    $columns[$row['column_name']] = $row['data_type'];
                }
            }
#7

Hop Studios

7 days ago

Hey Brian,

Yeah this is kind of weird but when I add

echo '<pre>';
print_r($schemaQuery->result());
echo '</pre><p>‘;</pre>
on the local env I get the lowercase properties which is different from the staging site.

I also tried to run the query

select column_name, data_type from `information_schema`.`columns` where `table_schema` = “sfai_dev” and `table_name` in(‘exp_channel_data’);

in command line (both staging site and local) and their results are different as well (the staging having the uppercase COLUMN_NAME, DATA_TYPE even though the select query is getting the column names in lowercase).

#8

BoldMinded (Brian)

6 days ago

Thanks for the feedback. If that is the case, then my change in comment #6 should work in 5.7 and 8.

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.