Skip to content

Commit b293f06

Browse files
authored
Tombstone: Add remove method (#2116)
1 parent db698ad commit b293f06

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: minor
2+
Type: added
3+
4+
Adds support for virtual deletes and restores, allowing objects to be removed from the fediverse without being deleted locally.

includes/class-tombstone.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,4 +207,19 @@ public static function bury( $url ) {
207207

208208
\update_option( 'activitypub_tombstone_urls', $urls );
209209
}
210+
211+
/**
212+
* Remove a URL from the local tombstone registry.
213+
*
214+
* Removes a URL from the local tombstone URL registry.
215+
* The URL is normalized before comparison to ensure consistent matching.
216+
* This marks the URL as no longer tombstoned for future local checks.
217+
*
218+
* @param string $url The URL to remove from the tombstone registry.
219+
*/
220+
public static function remove( $url ) {
221+
$urls = \get_option( 'activitypub_tombstone_urls', array() );
222+
$urls = \array_diff( $urls, array( normalize_url( $url ) ) );
223+
\update_option( 'activitypub_tombstone_urls', $urls );
224+
}
210225
}

tests/includes/class-test-tombstone.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,24 @@ public function test_exists_local() {
162162

163163
\delete_option( 'activitypub_tombstone_urls' );
164164
}
165+
166+
/**
167+
* Tests that the remove method removes a URL from the tombstone list,
168+
* so that exists_local returns false after removing.
169+
*
170+
* @covers ::remove
171+
*/
172+
public function test_remove() {
173+
$url = 'https://fake.test/object/123';
174+
175+
Tombstone::bury( $url );
176+
177+
$response = Tombstone::exists_local( $url );
178+
$this->assertTrue( $response );
179+
180+
Tombstone::remove( $url );
181+
182+
$response = Tombstone::exists_local( $url );
183+
$this->assertFalse( $response );
184+
}
165185
}

0 commit comments

Comments
 (0)