API page: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21...

This is incorrect:

 in Drupal 8.0.0, intended to be removed in Drupal 9.0.0 Please use toLink() instead.

Should say that it's toLink()->toString() instead. Developers copying the code given here will find it doesn't work!

Also the @see to toLink() is broken, probably missing the ().

Comments

joachim created an issue. See original summary.

fredysan’s picture

StatusFileSize
new691 bytes

Please review

fredysan’s picture

Status: Active » Needs review
joachim’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for the patch!

LGTM.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

We need to update the corresponding @trigger_error() here

  /**
   * {@inheritdoc}
   */
  public function link($text = NULL, $rel = 'canonical', array $options = []) {
    @trigger_error("EntityInterface::link() is deprecated in Drupal 8.0.0 and will be removed in Drupal 9.0.0. EntityInterface::toLink() instead. Note, the default relationship for configuration entities changes from 'edit-form' to 'canonical'. See https://www.drupal.org/node/2614344", E_USER_DEPRECATED);
    return $this->toLink($text, $rel, $options)->toString();
  }

too.

fredysan’s picture

StatusFileSize
new1.73 KB

Please review.

fredysan’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 6: 3059564-6-update-depecation-message.patch, failed testing. View results

yogeshmpawar’s picture

Assigned: Unassigned » yogeshmpawar
yogeshmpawar’s picture

Assigned: yogeshmpawar » Unassigned
Status: Needs work » Needs review
StatusFileSize
new2.74 KB
new1.01 KB

Updated patch added with an interdiff.

Status: Needs review » Needs work

The last submitted patch, 10: 3059564-10.patch, failed testing. View results

yogeshmpawar’s picture

Status: Needs work » Needs review
StatusFileSize
new2.75 KB
new1.02 KB

Updated patch with an interdiff.

init90’s picture

Status: Needs review » Needs work

Looks like changes was added to improper place. According to the task description need to update deprecated message for link() method, but in a patch the message ancidentally have been updated for url() method.

init90’s picture

Status: Needs work » Needs review
StatusFileSize
new2.74 KB
new951 bytes

Updated patch.

joachim’s picture

Status: Needs review » Reviewed & tested by the community
alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed 1546b4b85a to 8.8.x and 0dbceaa4eb to 8.7.x. Thanks!

We have a thing about not using the word Please so I've remove that from the deprecation message on commit. I've checked that the CR also agrees with this advice. One thing that complicates this a bit is that there times when calling toString() is no longer needed at the point you were calling ::link() but it is the most direct replacement so I guess this is fine.

Also fixed the @see mentioned in the issue summary.

diff --git a/core/lib/Drupal/Core/Entity/EntityInterface.php b/core/lib/Drupal/Core/Entity/EntityInterface.php
index 8f88b39789..e2b5b8ef9b 100644
--- a/core/lib/Drupal/Core/Entity/EntityInterface.php
+++ b/core/lib/Drupal/Core/Entity/EntityInterface.php
@@ -189,10 +189,10 @@ public function url($rel = 'canonical', $options = []);
    *   An HTML string containing a link to the entity.
    *
    * @deprecated in Drupal 8.0.0, intended to be removed in Drupal 9.0.0
-   *   Please use \Drupal\Core\EntityInterface::toLink()->toString() instead.
+   *   Use \Drupal\Core\EntityInterface::toLink()->toString() instead.
    *
    * @see https://www.drupal.org/node/2614344
-   * @see \Drupal\Core\Entity\EntityInterface::toLink
+   * @see \Drupal\Core\Entity\EntityInterface::toLink()
    */
   public function link($text = NULL, $rel = 'canonical', array $options = []);
 

  • alexpott committed 1546b4b on 8.8.x
    Issue #3059564 by yogeshmpawar, fredysan, init90, joachim, alexpott:...

  • alexpott committed 0dbceaa on 8.7.x
    Issue #3059564 by yogeshmpawar, fredysan, init90, joachim, alexpott:...

Status: Fixed » Closed (fixed)

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