Comments

chr.fritsch’s picture

Status: Active » Needs review
StatusFileSize
new5.39 KB

Here is the patch for flag 3. Flag 2 will also be supported

https://drupal.org/node/1922484 is also in these patch

ultimike’s picture

@chr.fritsch,

Thanks for the patch. I just expanded it a bit to include support for flags on taxonomy terms. Patch attached.

Thanks,
-mike

DrupalChimp’s picture

The count functionality was calling for a condition that entity_id = entity_type and so therefore not working. I have changed this to entity_id

pianomansam’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

I can confirm that the last patch works. I'm marking this as RTBC, but some action must be taken as the description for this module says it supports the flag module with no mention that the released vesion doesn't support the latest flag module!

kscheirer’s picture

RTBC from me too, this patch worked great. It's a little awkward to have to specify the fid of the new flag you're importing, but otherwise worked great.

joachim’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/flag.inc
    @@ -9,8 +9,30 @@
    +      $this->entity_id = 'content_type';
    +      $this->entity_type = 'content_id';
    

    Those look like they are the wrong way round.

  2. +++ b/flag.inc
    @@ -36,9 +68,11 @@ class MigrateDestinationFlagSimple extends MigrateDestination {
    -    db_delete('flag_content')
    -      ->condition('fcid', $ids, 'IN')
    +
    +    db_delete($this->table_name)
    +      ->condition($this->flagging_id, $ids, 'IN')
    

    Not related to this patch, but deleting one of Flag module's tables does NOT look like a good idea to me!!!

  3. +++ b/flag.inc
    @@ -54,51 +88,75 @@ class MigrateDestinationFlagSimple extends MigrateDestination {
    +    // Otherwise, clear out the fcid, just to be safe.
    

    Comment still uses the old ID field name.

  4. +++ b/flag.inc
    @@ -54,51 +88,75 @@ class MigrateDestinationFlagSimple extends MigrateDestination {
    -    if (!empty($entity->fcid)) {
    -      $return = drupal_write_record('flag_content', $entity, 'fcid');
    +    if (!empty($entity->{$this->flagging_id})) {
    +      $return = drupal_write_record($this->table_name, $entity, array($this->flagging_id));
         }
         else {
    -      $return = drupal_write_record('flag_content', $entity);
    +      $return = drupal_write_record($this->table_name, $entity);
         }
    

    Again, not related to this patch as the problem already exists, but it's not advised to write data to Flag tables directly -- you should be going via the API.

berenddeboer’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new6.09 KB

joachim raised only one valid point, addressed in attached patch.

joachim’s picture

I'm not sure which one you mean... both 1 and 3 are relevant here, aren't they? And 2 and 4 require a new issue filing -- otherwise successive migrations and rollbacks will totally mess up the flag_counts table.

jcandan’s picture

@joachim, the delete statements do not remove tables; notice the condition statements which delete specific rows during rollback.

Since Migrate Extras recommends implementation within contributed modules, I've included a destination class from the Migrate Extras module into the Flag module (https://www.drupal.org/node/2503815#comment-10810836), and implemented this latest patch to handle version 3 and below of the Flag module.

joachim’s picture

Status: Reviewed & tested by the community » Closed (won't fix)

I'm happy for work on this to carry on over on Flag module. This should be closed as won't fix.