getVocabularyId() not available in Drupal 9

Created on 2 February 2022, almost 3 years ago
Updated 21 August 2023, about 1 year ago

Problem/Motivation

A user we help support to use this module reports that there's a problem using the module under Drupal 9. Sample error message:

Updating taxonomy Subject ... Add to Default shortcuts
An error has occurred.
Please continue to the error page
An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /batch?id=191372&op=do_nojs&op=do
StatusText: parsererror
ResponseText:
TYPE
DATE
MESSAGE
USER
OPERATIONS
php 01/17/2022 - 11:49 Error: Call to undefined method
Drupal\taxonomy\Entity\Term::getVocabularyId() in
Drupal\pp_taxonomy_manager\PPTaxonomyManager->updateHashData() (line 1657
of /code/web/modules/contrib/pp_taxonomy_manager/src/PPTaxonomyManager.php)
#0 /code/web/modules… sys-admin-apo-…
php 01/17/2022 - 11:47 Error: Class 'EasyRdf_Http' not found in
Drupal\semantic_connector\Entity\SemanticConnectorSparqlEndpointConnection->getApi()
(line 82 of
/code/web/modules/contrib/semantic_connector/src/Entity/SemanticConnectorSparqlEndpointConnection.php)

Steps to reproduce

Use the module under Drupal 9.

Proposed resolution

The module's file src/PPTaxonomyManager.php uses getVocabularyId() in two places. In each of those two places, use bundle() instead. So:

Change line 1630 from:

'vid' => $term->getVocabularyId(),

to:

'vid' => $term->bundle(),

Change line 1657 from:

$update_query->condition('vid', $term->getVocabularyId());

to:

$update_query->condition('vid', $term->bundle());

The user reports that this change fixes the problem if these changes are made, as well as the patch https://www.drupal.org/files/issues/2020-06-16/pp_taxonomy_manager.1.x-dev.rector.patch
at https://www.drupal.org/project/pp_taxonomy_manager/issues/3148468 📌 Automated Drupal 9 compatibility fixes Fixed is also applied.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇦🇺Australia richard.walker.ardc

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024