After updating to 3.0-rc1, the entity updates are never completed, we continue to see

solr_field_type entity type :
The Solr Field Type entity type needs to be installed.
Do you wish to run all pending updates? (y/n):

The update never works and it will re-run over and over, with the deprecation notice:

EntityDefinitionUpdateManagerInterface::applyUpdates() is deprecated in 8.7.0 and will be removed before Drupal 9.0.0. Use [notice]
\Drupal\Core\Entity\EntityDefinitionUpdateManagerInterface::getChangeList() and execute each entity type and field storage update manually
instead. See https://www.drupal.org/node/3034742. EntityDefinitionUpdateManager.php:175

We are running Drupal core 8.7, where automatic updates are not supported, so something about the module update is not correct it appears.

CommentFileSizeAuthor
#12 3061334_12.patch3.82 KBsagesolutions
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

justageek created an issue. See original summary.

mkalkbrenner’s picture

Status: Active » Postponed (maintainer needs more info)

Why are you updating to 3.0-rc1? Update to 3.1 instead.

The "error" looks strange. Today I run various upgrades to 3.1 starting from different previous versions - also on core 8.7.
And I never faced such a message.

Can you provide more details on ...
- which commands you run?
- which update hook failed?
- stack traces?
- which version of search_api_solr was installed before?

mkalkbrenner’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

no feedback provided

sagesolutions’s picture

Status: Closed (cannot reproduce) » Active
Related issues: +#3047183: Mismatched entity and/or field definitions -- not fixed by drush entity-updates

I also have the same issue

Mismatched entity and/or field definitions
The following changes were detected in the entity type and field definitions.
Solr Field Type
The Solr Field Type entity type needs to be installed.

This happened when I upgraded from Search API Solr 8.x-1.2 to 8.x-3.2
I also upgraded Search API from 8.x-1.13 to 8.x-1.14
I am currently on Drupal 8.7.5

I ran drush updb and there were quite a number of updates, but all of them completed successfully (or no warnings at least).

From looking at the module, Im guessing search_api_solr_update_8200 installs the Solr Field Types based on the comment above it, but it also completed without error.

mkalkbrenner’s picture

Status: Active » Postponed (maintainer needs more info)

You said that all updates succeeded without any error messages. So, when do you see "Mismatched entity and/or field definitions" exactly?
If it occurs after the update, does "drush cr" help?

Which drush version are you using?

Does the same thing happen if you update via the web interface?

mkalkbrenner’s picture

Version: 8.x-3.0-rc1 » 8.x-3.x-dev

BTW the upgrade path was developed with Drupal 8.6 and drush 9.6. It might be, that something changed with drupal 8.7 and drush 9.7.

mkalkbrenner’s picture

sagesolutions’s picture

Status: Postponed (maintainer needs more info) » Active

The error message shows on the status report page at /admin/reports/status, and persists after running drush cr.

Trying to run drush entup returns the following:

Drupal removed its automatic entity-updates API in 8.7. See https://www.drupal.org/node/3034742.

I am using drush version 9.7.1

drush -V
Drush Commandline Tool 9.7.1
sagesolutions’s picture

After some research, I ended up downloading and installing https://www.drupal.org/project/devel_entity_updates

Once enabled, I ran drush entup which gave me the following:

drush entup
The following updates are pending:

solr_field_type entity type : 
The Solr Field Type entity type needs to be installed.

 Do you wish to run all pending updates? (yes/no) [yes]:
 > y

 [success] Finished performing updates.

Once completed, the mismatched entity error went away. Not a great solution, but one that got the job done!

sagesolutions’s picture

Ok so I also figured that instead of using the module, I can install the entity type programmatically. If someone else needs this, simply add this to a custom module .install file and run drush updb to remove the warning.

use Drupal\Core\Config\Entity\ConfigEntityType;
use Drupal\Core\StringTranslation\TranslatableMarkup;


/**
 * Installs the Solr Field Type entity type.
 *
 * @see https://www.drupal.org/project/search_api_solr/issues/3061334
 * @see https://www.drupal.org/node/3034742
 *
 * @throws \Drupal\Core\Entity\Exception\EntityTypeIdLengthException
 */
function my_module_update_8001() {
  \Drupal::entityDefinitionUpdateManager()
    ->installEntityType(new ConfigEntityType([
      'id' => 'solr_field_type',
      'label' => new TranslatableMarkup('Solr Field Type'),
      'handlers' => [
        'list_builder' => 'Drupal\search_api_solr\Controller\SolrFieldTypeListBuilder',
        'form' => [
          'add' => 'Drupal\search_api_solr\Form\SolrFieldTypeForm',
          'edit' => 'Drupal\search_api_solr\Form\SolrFieldTypeForm',
          'delete' => 'Drupal\search_api_solr\Form\SolrFieldTypeDeleteForm',
        ],
      ],
      'config_prefix' => 'solr_field_type',
      'admin_permission' => 'administer search_api',
      'entity_keys' => [
        'id' => 'id',
        'label' => 'label',
        'uuid' => 'uuid',
      ],
      'links' => [
        'edit-form' => '/admin/config/search/search-api/solr_field_type/{solr_field_type}',
        'delete-form' => '/admin/config/search/search-api/solr_field_type/{solr_field_type}/delete',
        'disable-for-server' => '/admin/config/search/search-api/server/{search_api_server}/solr_field_type/{solr_field_type}/disable',
        'enable-for-server' => '/admin/config/search/search-api/server/{search_api_server}/solr_field_type/{solr_field_type}/enable',
        'collection' => '/admin/config/search/search-api/server/{search_api_server}/solr_field_type',
      ],
    ]));
}

Im not sure if this should be a patch or not. It could replace the search_api_solr_update_8200() function maybe, or maybe its should be its own new update function search_api_solr_update_83xx() ?

mkalkbrenner’s picture

Status: Active » Needs work

Wow, thank you!

This piece of code should become part of update hook 8200()!

sagesolutions’s picture

Status: Needs work » Needs review
FileSize
3.82 KB

Updated search_api_solr_update_8200() with attached patch. Please review!

Thanks!

mkalkbrenner’s picture

  1. +++ b/search_api_solr.install
    @@ -432,12 +433,42 @@ function search_api_solr_update_8008() {
       // 8.x-1.x to 8.x-2.x migration path is obsolete and therefore removed. Just
       // install the latest field types.
    

    The comment is still valid.

  2. +++ b/search_api_solr.install
    @@ -432,12 +433,42 @@ function search_api_solr_update_8008() {
       search_api_solr_update_helper_install_configs();
    

    Are you sure that this line isn't required?
    Shouldn't it be called after the Field Type entity is installed?
    Or will this installation implicitly install all instances?

  3. +++ b/search_api_solr.install
    @@ -936,7 +967,9 @@ function search_api_solr_update_8308() {
    + * Solarium 5 adjustments. Warning! If you have overwritten the connection
    + * settings, don't forget to adjust the 'path'. See the release notes for
    + * details.
    
    @@ -1175,12 +1208,19 @@ function search_api_solr_update_8314() {
    + * Avoid Solr exceptions when multilingual spell checking by using unified
    + * analyzer.
    

    In former drush/core versions only the first line of the comment was printed on console. We need to check if that changed.

mkalkbrenner’s picture

Status: Needs review » Fixed

I tested another 1.x to 3.x upgrade and it worked. Thanks for your contribution!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.