Support from Acquia helps fund testing for Drupal Acquia logo

Comments

martin107’s picture

When I was looking at a patch for #2465865: Change FlagService::flag() and ::unflag() to use objects to discourage use of IDs

My take on this bug was that

unflagByObject and unflag would have to be merged some how

and as well as the flag count being an issue -- well the handling of $account was also inconsistent and the merge would have to deal with that too.

I am suddenly busy -- will be silent for a few days..:(

joachim’s picture

I'd rather we fix this bug first, so the commit history records a clear bug fix, separately from a refactor. Makes git blame and bisect much easier.

joachim’s picture

Assigned: Unassigned » joachim

Assigning myself to this one then!

Thanks for all your contributions recently -- hope to see you again in the issue queue in future! (Also, BTW, I think I saw you're in the UK. Drop on in #drupal-uk on IRC sometime! :)

joachim’s picture

Issue tags: +Needs tests
joachim’s picture

Uhoh. I have a bad feeling about this:

    $counts[$flag_name] = db_select('flag_counts', 'fc')
      ->fields('fc', array('flagging_id'))
      ->condition('fid', $flag->fid)

Flags don't have a fid and haven't for ages. I suspect all our flag count API functions are broken!

joachim’s picture

Status: Active » Postponed
socketwench’s picture

Looks like we missed adding test coverage for this too. >_<

joachim’s picture

Status: Postponed » Active

We can't commit broken tests, so we need to fix this here, and add basic tests here, which we can then refine when the flag count API is fixed.

joachim’s picture

The last submitted patch, 9: 2466253-9.flag_.unflag-object-flag-counts-tests-only.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 9: 2466253-9.flag_.unflag-object-flag-counts.patch, failed testing.

joachim’s picture

Weird. The patch fixes the problem for me when I try it by hand.

joachim’s picture

Sigh...

-    $this->assertTrue($flag_count_flagged = $flag_count_pre + 1, "The flag count was incremented.");
+    $this->assertEqual($flag_count_flagged, $flag_count_pre + 1, "The flag count was incremented.");

I guess one reason we have assertEqual() is that it means you can't make the mistake I made of using = instead of ==.

joachim’s picture

Status: Needs work » Needs review
joachim’s picture

Argh, how do I trigger the testbot?

martin107’s picture

Sometimes the only way is to re-upload. let see if this takes.

joachim’s picture

The last submitted patch, 16: 2466253-13.flag_.unflag-object-flag-counts-tests-only.patch, failed testing.

The last submitted patch, 13: 2466253-13.flag_.unflag-object-flag-counts-tests-only.patch, failed testing.

martin107’s picture

Issue tags: -Needs tests

Yes when the problem is laid bare.... it is obvious decrementFlagCounts() in the wrong place...

Tests look good and complete to me :)

So +1.

[Also This is a blocker so it would be good to get in. ]

joachim’s picture

Status: Needs review » Reviewed & tested by the community

I'm going to call that an RTBC and commit it. Thanks for the review!

joachim’s picture

Status: Reviewed & tested by the community » Fixed

  • joachim committed b633621 on 8.x-4.x
    Issue #2466253 by joachim: Fixed FlagService::unflagByObject() failing...

Status: Fixed » Closed (fixed)

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