Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Fix returned count of delete extremities admin API (#12496)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikjohnston authored Apr 19, 2022
1 parent b80bb7e commit c1482a3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog.d/12496.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix bug where the admin API for [deleting forward extremities](https://github.com/matrix-org/synapse/blob/erikj/fix_delete_event_response_count/docs/admin_api/rooms.md#deleting-forward-extremities) would always return a count of 1 no matter how many extremities were deleted. Broke in v1.27.0.
8 changes: 5 additions & 3 deletions synapse/storage/databases/main/events_forward_extremities.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,23 @@ def delete_forward_extremities_for_room_txn(txn: LoggingTransaction) -> int:
"""

txn.execute(sql, (event_id, room_id))

deleted_count = txn.rowcount
logger.info(
"Deleted %s extra forward extremities for room %s",
txn.rowcount,
deleted_count,
room_id,
)

if txn.rowcount > 0:
if deleted_count > 0:
# Invalidate the cache
self._invalidate_cache_and_stream(
txn,
self.get_latest_event_ids_in_room,
(room_id,),
)

return txn.rowcount
return deleted_count

return await self.db_pool.runInteraction(
"delete_forward_extremities_for_room",
Expand Down

0 comments on commit c1482a3

Please sign in to comment.