Problem/Motivation

      @trigger_error('Automatically creating the first item for computed fields is deprecated in Drupal 8.5.x and will be removed before Drupal 9.0.0. Use \Drupal\Core\TypedData\ComputedItemListTrait instead.', E_USER_DEPRECATED);

\Drupal\Core\TypedData\Plugin\DataType\ItemList::get() should include field name/entity type or so in the message, because it's pretty annoying to even track down right now what is causing it.

Proposed resolution

Add more context.

Remaining tasks

Do it!

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

N/A

Comments

jibran created an issue. See original summary.

wim leers’s picture

Issue tags: +Novice, +php-novice, +DX (Developer Experience)

👍

hchonov’s picture

+1.

jibran’s picture

Status: Active » Needs review
StatusFileSize
new1.17 KB

How about this?

berdir’s picture

Not sure if the name is enough, maybe $entity_type_id.$field_name? Or maybe the field type instead, becaue the implementation is based on the field type, not name. And that's what you have to look up in the end. Also, I think we usually don't use sprintf().

jungle’s picture

StatusFileSize
new1.22 KB

Append this issue link to the message.

BTW, at the commit 32f4d3e44c found 23 matches of 16 files used sprintf() inside trigger_error()

hchonov’s picture

Status: Needs review » Needs work

I don't think that it is important if we use sprintf() or not, but we definetly should add more information as suggested in #5:

Not sure if the name is enough, maybe $entity_type_id.$field_name? Or maybe the field type instead, becaue the implementation is based on the field type, not name.

I think that the field type is more important, but we could add not only it, but the entity type and field name as well.

jungle’s picture

Append this issue link to the message.

Sorry, maybe a wrong link appended. If there is a link, it should be the link of change record. Ignore it, please.

jungle’s picture

Status: Needs work » Needs review
StatusFileSize
new2.81 KB

$field_label(entity type: $entity_type_id, bundle: $bundle, field name: $field_name) added.

And the change record link appended.

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

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

martin107’s picture

Issue tags: -

Just posting a users perspective..

Grumpily -- I saw the old error message ... googled for help .. found this issue .. applied the patch
and after was happy that it pin pointed the error. ... Happiness.

Here is the improved error report.

./vendor/bin/phpunit -c core/ modules/contrib/flag/tests/src/Functional/LinkTypeAjaxTest.php 
PHPUnit 6.5.14 by Sebastian Bergmann and contributors.

Testing Drupal\Tests\flag\Functional\LinkTypeAjaxTest
E                                                                   1 / 1 (100%)

Time: 14.26 seconds, Memory: 6.00MB

There was 1 error:

1) Drupal\Tests\flag\Functional\LinkTypeAjaxTest::testNoJavascriptResponse
Exception: Notice: Undefined offset: 0
Drupal\Core\TypedData\Plugin\DataType\ItemList->get()() (Line: 105)


/var/www/html/web/core/lib/Drupal/Core/Test/HttpClientMiddleware/TestHttpClientMiddleware.php:51
/var/www/html/web/vendor/guzzlehttp/promises/src/Promise.php:203
/var/www/html/web/vendor/guzzlehttp/promises/src/Promise.php:156
/var/www/html/web/vendor/guzzlehttp/promises/src/TaskQueue.php:47
/var/www/html/web/vendor/guzzlehttp/promises/src/Promise.php:246
/var/www/html/web/vendor/guzzlehttp/promises/src/Promise.php:223
/var/www/html/web/vendor/guzzlehttp/promises/src/Promise.php:267
/var/www/html/web/vendor/guzzlehttp/promises/src/Promise.php:225
/var/www/html/web/vendor/guzzlehttp/promises/src/Promise.php:62
/var/www/html/web/vendor/guzzlehttp/guzzle/src/Client.php:131
/var/www/html/web/vendor/fabpot/goutte/Goutte/Client.php:180
/var/www/html/web/vendor/symfony/browser-kit/Client.php:407
/var/www/html/web/vendor/symfony/browser-kit/Client.php:292
/var/www/html/web/vendor/behat/mink-browserkit-driver/src/BrowserKitDriver.php:477
/var/www/html/web/vendor/behat/mink/src/Element/NodeElement.php:153
/var/www/html/web/core/tests/Drupal/Tests/UiHelperTrait.php:496
/var/www/html/web/modules/contrib/flag/tests/src/Functional/LinkTypeAjaxTest.php:68
jibran’s picture

+++ b/core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php
@@ -101,7 +102,36 @@ public function get($index) {
+      if ($first_item instanceof FieldItemInterface) {

What about we move this statement to \Drupal\Core\Field\FieldItemBase class?

mradcliffe’s picture

Issue tags: -Novice

I removed the Novice tag because I do not think there are any more actionable tasks for Novices with the pending question for review by @jibran.

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

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now 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.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new143 bytes

The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

quietone’s picture

Status: Needs work » Closed (outdated)

This deprecation message was removed in #3104307: Remove BC layers in various Drupal\Core components

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.