Problem/Motivation

EntityInterface->getSystemPath() is deprecated and will be removed on Drupal 8.0.x

Proposed resolution

Replace all usage with EntityInterface->urlInfo()
Remove all implementations and definition from interface

Remaining tasks

create patch
fix tests

User interface changes

no

API changes

Removal of EntityInterface->getSystemPath() and all implementations

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Task because this issue does not fix anything that's broken, other than deprecation.
Issue priority Normal because it's not a pressing issue.
Prioritized changes Prioritized because the main goal of this issue is removing code already deprecated for 8.0.0
Disruption Disruptive for contributed and custom modules which still use the deprecated method EntityInterface->getSystemPath()
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

andypost’s picture

Berdir’s picture

There is exactly one call to it in core. And that's the test for that method.

There's no need to remove that separately.

mathankumarc’s picture

Assigned: Unassigned » mathankumarc
tadityar’s picture

Status: Active » Needs review
FileSize
2.37 KB

Found another one in CommentTranslationUITest (?)

Status: Needs review » Needs work

The last submitted patch, 4: 2476059-remove-getsystempath-4.patch, failed testing.

andypost’s picture

Issue summary: View changes

Use $entity->urlInfo()

+++ b/core/modules/comment/src/Tests/CommentTranslationUITest.php
@@ -138,7 +138,7 @@ protected function doTestPublishedStatus() {
+    $path = $entity->static::urlInfo('edit-form');

it's not static method

tadityar’s picture

Status: Needs work » Needs review
FileSize
2.36 KB
605 bytes

Status: Needs review » Needs work

The last submitted patch, 7: 2476059-remove-getsystempath-7.patch, failed testing.

mathankumarc’s picture

+++ b/core/modules/comment/src/Tests/CommentTranslationUITest.php
@@ -138,7 +138,7 @@ protected function doTestPublishedStatus() {
+    $path = $entity->urlInfo('edit-form');

Just changing to urlInfo makes that particular test case to fail. Need to troubleshoot to get more info about this test case execution

Berdir’s picture

  1. +++ b/core/modules/comment/src/Tests/CommentTranslationUITest.php
    @@ -138,7 +138,7 @@ protected function doTestPublishedStatus() {
         $entity = entity_load($this->entityTypeId, $this->entityId, TRUE);
    -    $path = $entity->getSystemPath('edit-form');
    +    $path = $entity->urlInfo('edit-form');
    

    urlInfo returns an object, so you should rename it to $url.

    The problem is that you can't pass in the language to drupalPostForm() like the code below is doing if you have an object, instead you need to pass it to urlInfo().

    But that means you need to move the code inside the foreach loop, so you get a different object for each language.

  2. +++ b/core/tests/Drupal/Tests/Core/Entity/EntityUrlTest.php
    @@ -199,38 +199,6 @@ public function testUrl() {
    -   * Tests the getPathByAlias() method.
    -   *
    -   * @covers ::getSystemPath
    -   */
    -  public function testGetSystemPath() {
    -    $entity_type = $this->getMock('Drupal\Core\Entity\EntityTypeInterface');
    

    As I said, this is the test for the function. Removing the test without removing the method is wrong IMHO. That said, I don't think we need an issue to fix a single call, we can probably just remove it all here?

yarik.lutsiuk’s picture

Status: Needs work » Needs review
FileSize
5.26 KB
5.26 KB

removed usage and function with test

Status: Needs review » Needs work

The last submitted patch, 11: 2476059-remove-getsystempath-11.patch, failed testing.

willzyx’s picture

Status: Needs work » Needs review
FileSize
6.09 KB
Berdir’s picture

+++ b/core/modules/comment/src/Tests/CommentTranslationUITest.php
@@ -138,12 +138,12 @@ protected function doTestPublishedStatus() {
     foreach ($this->langcodes as $langcode) {
+      $path = $entity->urlInfo('edit-form', ['language' => $languages[$langcode], 'absolute' => TRUE])->toString();
       $user = $this->drupalCreateUser();

You can pass a UrlInfo() object to drupalPostForm(), that should eliminate the need for the absolute option and ->toString(), rename $path to $url then.

willzyx’s picture

Berdir’s picture

Status: Needs review » Needs work

Patch looks good to me now. I'm not aware of any contrib modules still using this, so we should be pretty safe.

Issue title needs to be updated to reflect that we are actually removing the method here.

And we need a beta evaluation and prepare a change record. The only mention that I can find is the introduction of the method in https://www.drupal.org/list-changes/published?keywords_description=getSy....

Once this is committed, we should also review that change record and update it for current standards.

willzyx’s picture

Title: Remove all calls to EntityInterface->getSystemPath() » Remove EntityInterface->getSystemPath(), all its implementations and related usage
Issue summary: View changes

Added beta evaluation and changed title

Berdir’s picture

Status: Needs work » Reviewed & tested by the community

Ok, this was deprecated a long time ago, so I think it's OK to remove it?

As mentioned above, couldn't find any contrib usages anyway and it was only introduced a year ago...

I don't think we need a new change record for this as mentioned, we can update the existing one and just remove this part, or if we want to we can say that if you really, really need the system path (path system still does for example), you can use $entity->urlInfo()->getInternalPath().

dawehner’s picture

+1 to the RTBC

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed c31fec2 and pushed to 8.0.x. Thanks!

Thanks for adding the beta evaluation to the issue summary.

  • alexpott committed c31fec2 on 8.0.x
    Issue #2476059 by willzyx, tadityar, yarik.lutsiuk, Berdir: Remove...
Maouna’s picture

Status: Fixed » Needs work

My patch in https://www.drupal.org/node/2497247 failed because of
Fatal error: Call to undefined method Drupal\block\Entity\Block::getSystemPath() in /var/lib/drupaltestbot/sites/default/files/checkout/sites/default/modules/token/src/Tests/TokenBlockTest.php on line 54
Can you please include that, too? Thanks!

Berdir’s picture

Status: Needs work » Fixed

token is a contrib module and already has a patch.

Status: Fixed » Closed (fixed)

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