EE compatibility updates:

  • Publisher is EE5 compatible, but it does not currently support the Fluid field.

ExpressionEngine.com licenses:

  • If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.

Ticket: Undefined variable: currentFieldType - when saving a field

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

Hop Studios

Dec 18, 2019

I just updated a client site to EE 5.3.0 and Publisher 3.1.0

I am getting this bug whenever I save an existing field. It is the same for all fields.

Notice
Undefined variable: currentFieldType
user/addons/publisher/Service/Schema/FieldSchema.php, line 303

Severity: E_NOTICE
Warning
Cannot modify header information - headers already sent by (output started at ee/legacy/core/Exceptions.php:120)
ee/legacy/core/Input.php, line 238

Severity: E_WARNING
Warning
Cannot modify header information - headers already sent by (output started at ee/legacy/core/Exceptions.php:120)
ee/legacy/libraries/Functions.php, line 393

Severity: E_WARNING

I was able to resolve the issue by adjusting this line of code (mentioned above: user/addons/publisher/Service/Schema/FieldSchema.php, line 303)

change:

if ($currentFieldType !== $fieldType) {

to:

if (isset($currentFieldType) && $currentFieldType !== $fieldType) {

Seems like the $currentFieldType variable is not being set in the previous if statement.

I could provide you with staging server access, but that will take me a bit of time to get the upgrade sync’d up to staging as we have just run it on Production.

Let me know if you have any suggestions. For now, I think its OK, as the work-around I did above seems to avoid the error, and the field does save still.

Thanks,
-Rowan

#1

Hop Studios

Dec 18, 2019

Also, i am getting this error when saving an entry:

Fatal error: Call to a member function getValues() on boolean in /home/bcinvas/public_html/contentzsystem/user/addons/publisher/Service/Entry/Entry.php on line 506

url is: https://bcinvasives.ca/admin.php?/cp/publish/edit/entry/3129&publisher_status=draft

#2

BoldMinded (Brian)

Dec 18, 2019

What was the previous version of EE and Publisher installed before the upgrade? Is this a custom field that is using the old schema in exp_channel_data or the new exp_channel_field_data_X table schema?

#3

BoldMinded (Brian)

Dec 18, 2019

For that second error, on line 501 of that file, try changing this

if ($defaultEntry === null) {

to

if (!$defaultEntry) {
#4

BoldMinded (Brian)

Dec 18, 2019

As for the first error, I’d probably change it to this instead of checking isset()

protected function updateTable($tableName, $fieldName, $fieldType = 'text')
    {
        $currentFieldType = null;
        $tableColumns = $this->getTableColumns($tableName);

        if (array_key_exists($tableName, $tableColumns)) {
            $fieldData = $tableColumns[$fieldName];
            $currentFieldType = $fieldData->Type;
        }

        if ($currentFieldType && $currentFieldType !== $fieldType) {
            ee('db')->query(sprintf('ALTER TABLE `%s` CHANGE `%s` `%s` %s',
                $tableName,
                $fieldName,
                $fieldName,
                $fieldType
            ));
        }
    }
#5

Hop Studios

Dec 18, 2019

Hey Brian,
I have made the two changes you have mentioned to the production server, and preliminary testing looks good. I will post again if those errors or others appear relating to Publisher.

The previous version of the site was running EE 4.3.6 and Publisher 2.11.2

I presume you have a workflow to incorporate those adjustments into your next release as needed?

For now, I think we’re in good shape.

Much appreciated
-rowan

#6

BoldMinded (Brian)

Dec 19, 2019

I presume you have a workflow to incorporate those adjustments into your next release as needed?

Yep, those changes are already in my Git repo, so they’ll be included in the next release. Thanks for pointing out the issues.

Login to reply

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