Errors due to deprecated features in core

Created on 24 July 2023, about 2 years ago

Problem/Motivation

My drupal-installation has started to report error for some of my content, in fact three errors are thrown.

An extract of the error log are shown below

Deprecated function: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in Drupal\Core\Url::fromUri() (line 281 of core/lib/Drupal/Core/Url.php).

Drupal\Core\Url::fromUri(NULL) (Line: 32)

Drupal\feeds\Plugin\Field\FieldType\FeedsItem->getUrl() (Line: 95)

Drupal\feeds\Plugin\Field\FieldFormatter\FeedsItemUrlFormatter->buildUrl(Object) (Line: 73)

Drupal\feeds\Plugin\Field\FieldFormatter\FeedsItemUrlFormatter->viewElements(Object, 'nb') (Line: 89)

Drupal\Core\Field\FormatterBase->view(Object, 'nb') (Line: 76)

Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceFormatterBase->view(Object, NULL) (Line: 265)

Drupal\Core\Entity\Entity\EntityViewDisplay->buildMultiple(Array) (Line: 266)

Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay->buildMultiple(Array) (Line: 223)

Drupal\Core\Entity\Entity\EntityViewDisplay->build(Object) (Line: 461)

Drupal\Core\Entity\EntityViewBuilder->viewField(Object, Array) (Line: 243)

Drupal\Core\Field\FieldItemList->view(Array) (Line: 171)

Drupal\ctools_block\Plugin\Block\EntityField->blockAccess(Object) (Line: 127)

Drupal\Core\Block\BlockBase->access(Object, 1) (Line: 124)
Deprecated function: parse_url(): Passing null to parameter #1 ($url) of type string is deprecated in Drupal\Core\Url::fromUri() (line 284 of core/lib/Drupal/Core/Url.php).

Drupal\Core\Url::fromUri(NULL) (Line: 32)

Drupal\feeds\Plugin\Field\FieldType\FeedsItem->getUrl() (Line: 95)

Drupal\feeds\Plugin\Field\FieldFormatter\FeedsItemUrlFormatter->buildUrl(Object) (Line: 73)

Drupal\feeds\Plugin\Field\FieldFormatter\FeedsItemUrlFormatter->viewElements(Object, 'nb') (Line: 89)

Drupal\Core\Field\FormatterBase->view(Object, 'nb') (Line: 76)

Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceFormatterBase->view(Object, NULL) (Line: 265)

Drupal\Core\Entity\Entity\EntityViewDisplay->buildMultiple(Array) (Line: 266)

Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay->buildMultiple(Array) (Line: 223)

Drupal\Core\Entity\Entity\EntityViewDisplay->build(Object) (Line: 461)

Drupal\Core\Entity\EntityViewBuilder->viewField(Object, Array) (Line: 243)

Drupal\Core\Field\FieldItemList->view(Array) (Line: 171)

Drupal\ctools_block\Plugin\Block\EntityField->blockAccess(Object) (Line: 127)

Drupal\Core\Block\BlockBase->access(Object, 1) (Line: 124)
Deprecated function: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in Drupal\Core\Url::fromUri() (line 289 of core/lib/Drupal/Core/Url.php).

Drupal\Core\Url::fromUri(NULL) (Line: 32)

Drupal\feeds\Plugin\Field\FieldType\FeedsItem->getUrl() (Line: 95)

Drupal\feeds\Plugin\Field\FieldFormatter\FeedsItemUrlFormatter->buildUrl(Object) (Line: 73)

Drupal\feeds\Plugin\Field\FieldFormatter\FeedsItemUrlFormatter->viewElements(Object, 'nb') (Line: 89)

Drupal\Core\Field\FormatterBase->view(Object, 'nb') (Line: 76)

Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceFormatterBase->view(Object, NULL) (Line: 265)

Drupal\Core\Entity\Entity\EntityViewDisplay->buildMultiple(Array) (Line: 266)

Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay->buildMultiple(Array) (Line: 223)

Drupal\Core\Entity\Entity\EntityViewDisplay->build(Object) (Line: 461)

Drupal\Core\Entity\EntityViewBuilder->viewField(Object, Array) (Line: 243)

Drupal\Core\Field\FieldItemList->view(Array) (Line: 171)

Drupal\ctools_block\Plugin\Block\EntityField->blockAccess(Object) (Line: 127)

Drupal\Core\Block\BlockBase->access(Object, 1) (Line: 124)

Steps to reproduce

When I looked into it, it is only imported items that causes problems. (It is an import of a structured text-file, manually initiated import) The reason probably being that the url-part of the feeds_item-field is null? See below. I may as well create content manually, those do not have this problem (as the entire field then is empty)

feeds_item => array (1)
    x-default => array (1)
       0 => array (5)
          target_id => string (2) "33"
          imported => string (10) "1623530674"
             2021-06-12 20:44:34 UTC
          url => null
          guid => string (0) ""
          hash => string (32) "525e35ea6b07109149ad2ebb490a8a2d"

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Component

Code

Created by

🇳🇴Norway oasweb Oslo

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

Merge Requests

Comments & Activities

  • Issue created by @oasweb
  • First commit to issue fork.
  • 🇩🇪Germany marco.b

    I habe similag log entries in zhe drupal watchdog.

    And I also have 6 times the same error message at the translation-add-for (/de/node/280/translations/add/pt-br/de). I assume this is an expression of the same issue. Here is the error message:

    Deprecated function: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in Drupal\Core\Url::fromUri() (line 281 of core/lib/Drupal/Core/Url.php).

    Drupal\Core\Url::fromUri() (Line: 37)
    Drupal\feeds\Plugin\Field\FieldType\FeedsItem->getUrl() (Line: 95)
    Drupal\feeds\Plugin\Field\FieldFormatter\FeedsItemUrlFormatter->buildUrl() (Line: 73)
    Drupal\feeds\Plugin\Field\FieldFormatter\FeedsItemUrlFormatter->viewElements() (Line: 91)
    Drupal\Core\Field\FormatterBase->view() (Line: 83)
    Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceFormatterBase->view() (Line: 275)
    Drupal\Core\Entity\Entity\EntityViewDisplay->buildMultiple() (Line: 233)
    Drupal\Core\Entity\Entity\EntityViewDisplay->build() (Line: 462)
    Drupal\Core\Entity\EntityViewBuilder->viewField() (Line: 121)
    Drupal\readonly_field_widget\Plugin\Field\FieldWidget\ReadonlyFieldWidget->formElement() (Line: 464)
    Drupal\Core\Field\WidgetBase->formSingleElement() (Line: 86)
    Drupal\readonly_field_widget\Plugin\Field\FieldWidget\ReadonlyFieldWidget->formMultipleElements() (Line: 120)
    Drupal\Core\Field\WidgetBase->form() (Line: 197)
    Drupal\Core\Entity\Entity\EntityFormDisplay->buildForm() (Line: 121)
    Drupal\Core\Entity\ContentEntityForm->form() (Line: 138)
    Drupal\node\Form\NodeForm->form() (Line: 107)
    Drupal\Core\Entity\EntityForm->buildForm()
    call_user_func_array() (Line: 528)
    Drupal\Core\Form\FormBuilder->retrieveForm() (Line: 279)
    Drupal\Core\Form\FormBuilder->buildForm() (Line: 48)
    Drupal\Core\Entity\EntityFormBuilder->getForm() (Line: 414)
    Drupal\content_translation\Controller\ContentTranslationController->add()
    call_user_func_array() (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 627)
    Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 183)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
    Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
    Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 116)
    Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 90)
    Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 263)
    Drupal\shield\ShieldMiddleware->bypass() (Line: 130)
    Drupal\shield\ShieldMiddleware->handle() (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 53)
    Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 715)
    Drupal\Core\DrupalKernel->handle() (Line: 19)

  • First commit to issue fork.
  • 🇳🇱Netherlands megachriz

    I see this is still an issue. It looks like that can only experience this issue when you configured the "Feeds item" to be displayed on an imported entity with the formatter set to "URL of the feed item" (the default formatter). By default, the "Feeds item" field is hidden, so that's why I did not noticed this issue myself before.

    I expect that the provided MR fixes the issue. Hopefully all tests pass.

Production build 0.71.5 2024