Problem/Motivation

Entity link templates are still route names instead of paths, and the names of the corresponding routes do not always start with entity..

Proposed resolution

  1. Convert link template values from route names to paths.
  2. Make sure the names of the routes belonging to link templates are prefixed with entity..

Remaining tasks

None.

User interface changes

None.

API changes

Route renames.

Data model changes

None.

Comments

edurenye’s picture

Status: Active » Needs review
StatusFileSize
new4.87 KB

Ok, solved the HEAD, now it don't break the tests, but I'm not sure if I have to add the entity before or I think is better like entity.flagging.delete_form or entity.flagging.confirm_unflag.

berdir’s picture

Status: Needs review » Needs work
  1. +++ b/flag.module
    @@ -277,13 +277,17 @@ function flag_user_account_removal(UserInterface $account) {
       foreach ($flaggings as $flagging_id => $flagging) {
    -    $flag_service->unflag($flagging->getFlag(), $flagging->getFlaggable(), $account);
    +    if ($flaggable = $flagging->getFlaggable()) {
    +      $flag_service->unflag($flagging->getFlag(), $flaggable, $account);
    +    }
       }
     
       // Remove flags that have been done to this user.
       $flaggings = $flag_service->getFlaggings(NULL, $account);
       foreach ($flaggings as $flagging_id => $flagging) {
    -    $flag_service->unflag($flagging->getFlag(), $flagging->getFlaggable());
    +    if ($flaggable = $flagging->getFlaggable()) {
    +      $flag_service->unflag($flagging->getFlag(), $flaggable);
    +    }
       }
    

    Looks like you have some unrelated local changes in the patch.

  2. +++ b/src/Entity/Flagging.php
    @@ -35,7 +35,7 @@ use Drupal\flag\FlaggingInterface;
      *  links = {
    - *    "delete-form" = "flag.confirm_unflag"
    + *    "delete-form" = "/flag/confirm/flag/{flag}/{entity_id}"
    

    A link template can't look like this, drupal doesn't know how to get values for flag/entity_id.

    If this is not possible for some reason (e.g. you don't want to have (flagging) instead in there (which means that links to that will need to load the flagging ID) first then it can't be a link template. You can still get the route directly.

    Note this never worked. You could not have called $flagging->url('delete-form') even before the route => link template conversion (which happened half a year ago, it was just not validated correctly)

    (this is a question to @joachim, not @edurenye).

edurenye’s picture

StatusFileSize
new433 bytes

Yes, sorry, now it's ok.

joachim’s picture

I'm not sure this is useful for flagging entities, and the right fix here might be in fact to remove it entirely. There's no admin UI for flaggings, there's no 'delete' link when you're editing a flagging. Deleting a flag is done via the unflagging UI instead.

berdir’s picture

Yeah, agree with that. Patch should remove the links part completely then.

edurenye’s picture

Status: Needs work » Needs review
StatusFileSize
new451 bytes
new469 bytes

Removed the links of the entity flagging.

berdir’s picture

Priority: Normal » Critical
Status: Needs review » Reviewed & tested by the community

Flag is currently completely broken and can't be installed, so I'd say this is critical :)

joachim’s picture

Status: Reviewed & tested by the community » Fixed

Committed.

Thanks everyone!

  • joachim committed 50323d6 on 8.x-4.x authored by edurenye
    Issue #2536380 by edurenye: Removed Flagging entity link template.
    

The last submitted patch, 1: fix_flagging_entity-2536380-1.patch, failed testing.

The last submitted patch, 3: fix_flagging_entity-2536380-3.patch, failed testing.

Status: Fixed » Closed (fixed)

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