Problem/Motivation

Workaround: If you encounter this error, update to 8.2.7 first and then update to 8.3.0.

If old schema cache entries are left around during an update they can get in the way.

Steps to reproduce:

  1. git co 8.1.1
  2. composer install
  3. drush si minimal
  4. drush en hal config -y
  5. drush config-edit rest.settings and change the link_domain - it actually not important but it is what I did.
  6. git co 8.3.0
  7. composer install
  8. drush updatedb -y
  9. BOOM

Here's the backtrace:

Error: Call to undefined method Drupal\Core\Config\Schema\Undefined::get() in Drupal\Core\Config\StorableConfigBase->castValue() (line [error]
179 of /Volumes/devdisk/dev/sites/drupal8alt.dev/core/lib/Drupal/Core/Config/StorableConfigBase.php) #0
/Volumes/devdisk/dev/sites/drupal8alt.dev/core/lib/Drupal/Core/Config/Config.php(212):
Drupal\Core\Config\StorableConfigBase->castValue('uuid', '8da39019-21f6-4...')
#1 /Volumes/devdisk/dev/sites/drupal8alt.dev/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php(280):
Drupal\Core\Config\Config->save(false)
#2 /Volumes/devdisk/dev/sites/drupal8alt.dev/core/lib/Drupal/Core/Entity/EntityStorageBase.php(392):
Drupal\Core\Config\Entity\ConfigEntityStorage->doSave('entity.node', Object(Drupal\rest\Entity\RestResourceConfig))
#3 /Volumes/devdisk/dev/sites/drupal8alt.dev/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php(259):
Drupal\Core\Entity\EntityStorageBase->save(Object(Drupal\rest\Entity\RestResourceConfig))
#4 /Volumes/devdisk/dev/sites/drupal8alt.dev/core/lib/Drupal/Core/Entity/Entity.php(364):
Drupal\Core\Config\Entity\ConfigEntityStorage->save(Object(Drupal\rest\Entity\RestResourceConfig))
#5 /Volumes/devdisk/dev/sites/drupal8alt.dev/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php(637):
Drupal\Core\Entity\Entity->save()
#6 /Volumes/devdisk/dev/sites/drupal8alt.dev/core/modules/rest/rest.post_update.php(25):
Drupal\Core\Config\Entity\ConfigEntityBase->save()
#7 /Volumes/devdisk/dev/sites/drupal8alt.dev/core/includes/update.inc(241):
rest_post_update_create_rest_resource_config_entities(Array)
#8 /Volumes/devdisk/dev/drush5/commands/core/drupal/batch.inc(163): update_invoke_post_update('rest_post_updat...',
Object(DrushBatchContext))
#9 /Volumes/devdisk/dev/drush5/commands/core/drupal/batch.inc(111): _drush_batch_worker()
#10 /Volumes/devdisk/dev/drush5/includes/batch.inc(98): _drush_batch_command('2')
#11 /Volumes/devdisk/dev/drush5/commands/core/drupal/update.inc(174): drush_batch_command('2')
#12 /Volumes/devdisk/dev/drush5/commands/core/core.drush.inc(1224): _update_batch_command('2')
#13 /Volumes/devdisk/dev/drush5/includes/command.inc(422): drush_core_updatedb_batch_process('2')
#14 /Volumes/devdisk/dev/drush5/includes/command.inc(231): _drush_invoke_hooks(Array, Array)
#15 /Volumes/devdisk/dev/drush5/includes/command.inc(199): drush_command('2')
#16 /Volumes/devdisk/dev/drush5/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
#17 /Volumes/devdisk/dev/drush5/includes/preflight.inc(66): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#18 /Volumes/devdisk/dev/drush5/drush.php(12): drush_main()
#19 {main}.

Proposed resolution

If we're in update don't use schema.

This is appears to be a drush bug - you need to be on version ^8.1.10 to have the fix.

Remaining tasks

User interface changes

None

API changes

?

Data model changes

None

Comments

alexpott created an issue. See original summary.

alexpott’s picture

alexpott’s picture

Issue summary: View changes
alexpott’s picture

Interestingly if you do:

  1. git co 8.1.1
  2. composer install
  3. drush si minimal
  4. drush en hal config -y
  5. drush config-edit rest.settings and change the link_domain - it actually not important but it is what I did.
  6. git co 8.2.0
  7. drush updatedb -y
  8. composer install
  9. git co 8.3.0
  10. composer install
  11. drush updatedb -y

There's no BOOM

wim leers’s picture

#2867113-11: Fatal error in serialization_update_8302() when updating to 8.3.0-rc2 reported this first:

PHP Fatal error:  Call to undefined method Drupal\Core\Config\Schema\Undefined::get() in /.../core/lib/Drupal/Core/Config/StorableConfigBase.php on line 179

The IS/STR also confirm this exact fatal error.


#4 referred to editing link_domain in rest.settings prior to updating from 8.2.x to 8.3.0. So, looked into that a bit. A few observations:

  1. Note that rest.settings until before 8.3.0 has this:
    link_domain: ~
    
  2. This is in rest.schema.yml, in 8.3.0:
    # Schema for the configuration files of the REST module.
    rest.settings:
      type: config_object
      label: 'REST settings'
      mapping:
        # @deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.0.
        link_domain:
          type: string
          label: 'Domain of the relation'
    

    i.e. link_domain is still there, specifically to not break config schema during upgrades.

  3. And this is in hal.schema.yml, in 8.3.0:
    # Schema for the configuration files of the HAL module.
    hal.settings:
      type: config_object
      label: 'HAL settings'
      mapping:
        link_domain:
          type: string
          label: 'Domain of the relation'
    

    i.e. the same.

  4. The error in the IS/STR is triggered by this code:
      protected function castValue($key, $value) {
        $element = $this->getSchemaWrapper()->get($key);
    

    Since it says Undefined::get() does not exist, getSchemaWrapper() must be returning an instance of \Drupal\Core\Config\Schema\Undefined, and that seems to be incorrect based on it being assigned the string type.

I don't know configuration system/configuration schema system internals well enough to make any educated guesses.

xjm’s picture

Assigned: catch » Unassigned
Issue summary: View changes

Adding the workaround alexpott found to the summary. Assuming this was not assigned to catch on purpose.

alexpott’s picture

Status: Active » Needs review
StatusFileSize
new1.34 KB

I think there are quire a few situations where this might bite - I agree with @Wim Leers's analysis of why this set of updates is biting.

I think the best solution is if the SchemaWrapper doesn't implement TypedConfigInterface don't call get() because that is where the get() method comes from. The patch attached passes the above steps to reproduce in the issue summary.

berdir’s picture

Apparently this happens when the whole config object itself has no type.

What I don't quite understand is that the call to this is wrapped in

if ($this->typedConfigManager->hasConfigSchema($this->name)) {
]

So if we have config schema then the type must always be a container and should always implement TypedConfigInterface.

It looks like we an inconsistency between that check and actually getting/creating a data definition? Are we clearing one cache but not the other?

catch’s picture

StatusFileSize
new478 bytes

If this is a real unexpected error condition then while the fatal is bad I'm not sure we should be that defensive, it could result in bad data in different circumstances.

Should we not just trust the data when we save the rest config entities in the post update?

alexpott’s picture

@catch I think my preference would be to disable schema during hook_update_N()

The last submitted patch, 2867444-9.patch, failed testing.

catch’s picture

This isn't hook_update_N() though, it's a post update that's supposed to have a full environment available. Not sure whether there's a use case to want schema in that case but maybe in the load and resave case to get things casted properly

alexpott’s picture

More info... if you do the above steps all via the UI it does not occur using the single import / export so there's something up with drush updates that makes this more likely.

alexpott’s picture

Issue summary: View changes

This is a drush bug - see https://github.com/drush-ops/drush/pull/2707 for drush 8.x and https://github.com/drush-ops/drush/pull/2706 for drush master

alexpott’s picture

Issue summary: View changes
catch’s picture

If this was fixed in February (in https://github.com/drush-ops/drush/issues/2617), what do we want to do here?

We could:

1. Commit this anyway since we trust the data
2. Re-purpose it to be a more useful error

Is it worth adding a note like 'If you're updating directly from 8.1.x to 8.3.x you should update drush first' to the release notes, on the other hand you're not really supposed to update from 8.1.x to 8.3.x directly.

berdir’s picture

Hm.

According to the report in #2867113: Fatal error in serialization_update_8302() when updating to 8.3.0-rc2, the person reporting that problem did not have drush installed at all. So it possibly isn't something *only* triggered by drush?

We probably need more info on previous version, installed modules, ..

catch’s picture

That was a hook_update_N(), this is a hook_post_update_FOO(), the important thing with this issue is the full cache clear/rebuild before the post updates run, which drush wasn't doing correctly. Enforcing schema in hook_update_N() needs to be ruled out possibly since we can't do a clean cache rebuild then so much.

Either way we do need to do something here about alternative code paths even if it's just better error handling.

alexpott’s picture

StatusFileSize
new1.46 KB

Here's another idea I had - basically to completely disable schema in hook_update_N - unfortunately this current implement would affect post updates too and I'm not convinced about that. Plus there's https://github.com/drush-ops/drush/pull/2627

berdir’s picture

I can't find anything in the comments from MmMnRr over there that he was running into a problem with the same update function as you did?

alexpott’s picture

@Berdir me neither I just tried to recreate it an found this. The full backtrace from @MmMnRr would be helpful but we never got that.

alexpott’s picture

xjm’s picture

I tried to run update.php again and for no reason it worked perfectly now.
So the issue is solved.

I tried multiple times to run update.php and I always received the same error. But now it worked.

I do not have drush installed in my server yet.
The trace came from the Apache log.
I checked the specific line referenced in the trace and it is the following:

(From the other issue.)

So it's not only drush, then.

Status: Needs review » Needs work

The last submitted patch, 19: 2867444-18.patch, failed testing.

xjm’s picture

#2861863: InvalidArgumentException "Field is unknown" in ContentEntityBase is another totally different fatal that goes away when running database updates multiple times. Hmm.

MmMnRr’s picture

Hi all,

I was trying to update from Drupal 8.1.1 to Drupal 8.3.0.
I do not have the full trace because I do not have drush installed. The only error message I got appeared on Apache log:

PHP Fatal error:  Call to undefined method Drupal\Core\Config\Schema\Undefined::get() in /.../core/lib/Drupal/Core/Config/StorableConfigBase.php on line 179

I followed the official Drupal Core update instructions:
https://www.drupal.org/docs/8/update/update-procedure-in-drupal-8

I tried to run update.php several times and it always failed.
Then I navigated through the website pages and tried again. The update worked perfectly then. Maybe the navigation triggered something but I have no proof.

The specific line referenced in the trace is the following:

/.../core/lib/Drupal/Core/Config/StorableConfigBase.php

protected function castValue($key, $value) {
    $element = $this->getSchemaWrapper()->get($key);

As the update has been done correctly now, I am unable to reproduce again the issue.

alexpott’s picture

@MmMnRr thanks for commenting. I'm glad you got your site updated. I guess that navigating to some other pages caused a config schema rebuild and that fixed this. Is there any chance that your webserver logs contain the full stack trace that lead to PHP Fatal error: Call to undefined method Drupal\Core\Config\Schema\Undefined::get().

MmMnRr’s picture

@alexpott The Apache log only included that message. Unfortunately, I do not have a more complete full stack trace.

alexpott’s picture

Priority: Critical » Major

Discussed with @catch, @Cottser, @effulgentsia, and @xjm. We decided that because the only known steps to reproduce involve outdated Drush versions this is not critical. There might be value in filing a follow-up issue to improve hook_update_N documentation to detail what is allowed and that config should be saved using the flag to ignore schema.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

quietone’s picture

Status: Needs work » Closed (outdated)
Issue tags: +Bug Smash Initiative

This issue concerns updating to a now non-supported Drupal version. I think that makes this outdated, closing as such.

Thanks folks!