Problem/Motivation

I added the mapbox field to a ECK bundle. When I attempt to edit it I get the following error:

The website encountered an unexpected error. Please try again later.

Error: Call to undefined function Drupal\mapbox_field\Plugin\Field\FieldWidget\drupal_get_path() in Drupal\mapbox_field\Plugin\Field\FieldWidget\MapboxWidget->formElement() (line 83 of modules/contrib/mapbox_field/src/Plugin/Field/FieldWidget/MapboxWidget.php).
Drupal\Core\Field\WidgetBase->formSingleElement() (Line: 216)
Drupal\Core\Field\WidgetBase->formMultipleElements() (Line: 111)
Drupal\Core\Field\WidgetBase->form() (Line: 287)
Drupal\Core\Field\FieldItemList->defaultValuesForm() (Line: 125)
Drupal\field_ui\Form\FieldConfigEditForm->form() (Line: 106)
Drupal\Core\Entity\EntityForm->buildForm()
call_user_func_array() (Line: 536)
Drupal\Core\Form\FormBuilder->retrieveForm() (Line: 283)
Drupal\Core\Form\FormBuilder->buildForm() (Line: 73)
Drupal\Core\Controller\FormController->getContentResult()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 163)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 74)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 58)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 686)
Drupal\Core\DrupalKernel->handle() (Line: 19)

Steps to reproduce

Fresh Drupal 10 install
composer require 'drupal/mapbox_field:^1.0'
drush en mapbox
drush en mapbox_field
Go into Mapbox and configure it with API token and the mapbox style and click save.
* Go to the structure for a Basic Page
* Click on manage fields
* Add a mapbox field
* Set storage settings to 1 and save
* Click on Edit for the map box field.

Proposed resolution

* Update the code so the error doesn't happen.

Remaining tasks

* Find spot where error is happening
* See what needs to be done.

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

jaimekristene created an issue. See original summary.

jaime@gingerrobot.com’s picture

Example from: drupal_get_path is removed from Drupal 10 must be replaced

https://www.drupal.org/project/entity_translation_unified_form/issues/32...

+      $path_to_etuf = \Drupal::service('extension.path.resolver')->getPath('module', 'entity_translation_unified_form');
+      if (file_exists($path_to_etuf . "/css/etuf-side-by-side-$theme.css")) {
jaime@gingerrobot.com’s picture

Issue summary: View changes

jaime@gingerrobot.com’s picture

Version: 1.0.6 » 1.0.x-dev
Priority: Normal » Critical
Issue summary: View changes
Status: Active » Needs review
jaime@gingerrobot.com’s picture

OK there is another error now :) I'll go commit the fix for this one.

The website encountered an unexpected error. Please try again later.

Error: Call to undefined function Drupal\mapbox_field\Plugin\Field\FieldFormatter\drupal_get_path() in Drupal\mapbox_field\Plugin\Field\FieldFormatter\MapboxFormatter->viewElements() (line 114 of modules/contrib/mapbox_field/src/Plugin/Field/FieldFormatter/MapboxFormatter.php)

roshni27’s picture

Assigned: jaime@gingerrobot.com » Unassigned
Priority: Critical » Normal

The solution provided above resolved the issue, and it's now ready to move to the "+1 RTBC" .

  • ahmed.raza committed 1d0a4388 on 1.0.x
    Issue #3366902: Undefined function drupal_get_path error on ECK mapbox...
ahmed.raza’s picture

Status: Needs review » Fixed

Thanks Jaime, though the solution needed some polishing which I've done. The new release 1.0.7 contains this fix.

ahmed.raza’s picture

Status: Fixed » Closed (fixed)