| @@ -192,59 +192,37 @@ | ||
| 192 | 192 | return false; |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | /** |
| 196 | - * Add one or more URLs to the local tombstone registry. | |
| 196 | + * Add a URL to the local tombstone registry. | |
| 197 | 197 | * |
| 198 | - * "Buries" URLs by adding them to the local tombstone URL registry. | |
| 199 | - * URLs are normalized before storage and duplicates are automatically removed. | |
| 200 | - * This marks the URLs as tombstoned for future local checks. | |
| 198 | + * "Buries" a URL by adding it to the local tombstone URL registry. | |
| 199 | + * The URL is normalized before storage and duplicates are automatically removed. | |
| 200 | + * This marks the URL as tombstoned for future local checks. | |
| 201 | 201 | * |
| 202 | - * @param string ...$urls The URLs to add to the tombstone registry. | |
| 202 | + * @param string $url The URL to add to the tombstone registry. | |
| 203 | + * | |
| 204 | + * @return void | |
| 203 | 205 | */ |
| 204 | - public static function bury( ...$urls ) { | |
| 205 | - $to_add = array(); | |
| 206 | + public static function bury( $url ) { | |
| 207 | + $urls = \get_option( 'activitypub_tombstone_urls', array() ); | |
| 208 | + $urls[] = normalize_url( $url ); | |
| 209 | + $urls = \array_unique( $urls ); | |
| 206 | 210 | |
| 207 | - foreach ( $urls as $url ) { | |
| 208 | - if ( \filter_var( $url, \FILTER_VALIDATE_URL ) ) { | |
| 209 | - $to_add[] = normalize_url( $url ); | |
| 210 | - } | |
| 211 | - } | |
| 212 | - | |
| 213 | - if ( empty( $to_add ) ) { | |
| 214 | - return; | |
| 215 | - } | |
| 216 | - | |
| 217 | - $stored_urls = \get_option( 'activitypub_tombstone_urls', array() ); | |
| 218 | - $stored_urls = \array_merge( $stored_urls, $to_add ); | |
| 219 | - $stored_urls = \array_unique( $stored_urls ); | |
| 220 | - | |
| 221 | - \update_option( 'activitypub_tombstone_urls', $stored_urls ); | |
| 211 | + \update_option( 'activitypub_tombstone_urls', $urls ); | |
| 222 | 212 | } |
| 223 | 213 | |
| 224 | 214 | /** |
| 225 | - * Remove one or more URLs from the local tombstone registry. | |
| 215 | + * Remove a URL from the local tombstone registry. | |
| 226 | 216 | * |
| 227 | - * Removes URLs from the local tombstone URL registry. | |
| 228 | - * URLs are normalized before comparison to ensure consistent matching. | |
| 229 | - * This marks the URLs as no longer tombstoned for future local checks. | |
| 217 | + * Removes a URL from the local tombstone URL registry. | |
| 218 | + * The URL is normalized before comparison to ensure consistent matching. | |
| 219 | + * This marks the URL as no longer tombstoned for future local checks. | |
| 230 | 220 | * |
| 231 | - * @param string ...$urls The URLs to remove from the tombstone registry. | |
| 221 | + * @param string $url The URL to remove from the tombstone registry. | |
| 232 | 222 | */ |
| 233 | - public static function remove( ...$urls ) { | |
| 234 | - $to_remove = array(); | |
| 235 | - | |
| 236 | - foreach ( $urls as $url ) { | |
| 237 | - if ( \filter_var( $url, \FILTER_VALIDATE_URL ) ) { | |
| 238 | - $to_remove[] = normalize_url( $url ); | |
| 239 | - } | |
| 240 | - } | |
| 241 | - | |
| 242 | - if ( empty( $to_remove ) ) { | |
| 243 | - return; | |
| 244 | - } | |
| 245 | - | |
| 246 | - $stored_urls = \get_option( 'activitypub_tombstone_urls', array() ); | |
| 247 | - $stored_urls = \array_diff( $stored_urls, $to_remove ); | |
| 248 | - \update_option( 'activitypub_tombstone_urls', $stored_urls ); | |
| 223 | + public static function remove( $url ) { | |
| 224 | + $urls = \get_option( 'activitypub_tombstone_urls', array() ); | |
| 225 | + $urls = \array_diff( $urls, array( normalize_url( $url ) ) ); | |
| 226 | + \update_option( 'activitypub_tombstone_urls', $urls ); | |
| 249 | 227 | } |
| 250 | 228 | } |