add log and try catch

This commit is contained in:
Tiger Ren 2025-01-01 20:56:16 +08:00
parent 592d586acb
commit 410ba6f6ca
1 changed files with 17 additions and 7 deletions

View File

@ -39,14 +39,24 @@ class TelegramLinkFixerExtension extends Minz_Extension
}
// Look specifically for Telegraph links
if (preg_match('/<a[^>]*?href="(https:\/\/telegra\.ph\/[^"]+)"[^>]*>Telegraph<\/a>/i', $description, $matches)) {
$telegraphLink = $matches[1];
if (!empty($telegraphLink)) {
error_log('TelegramLinkFixer: Found Telegraph link: ' . $telegraphLink);
// $entry->setLink($telegraphLink);
error_log('TelegramLinkFixer: Looking for Telegraph link in description: ' . $description);
try {
if (preg_match('/<a[^>]*?href="(https:\/\/telegra\.ph\/[^"]+)"[^>]*>Telegraph<\/a>/i', $description, $matches)) {
$telegraphLink = $matches[1];
if (!empty($telegraphLink)) {
Minz_Log::debug('TelegramLinkFixer: Found Telegraph link: ' . $telegraphLink);
try {
$entry->setLink($telegraphLink);
error_log('TelegramLinkFixer: Successfully updated link');
} catch (Exception $e) {
error_log('TelegramLinkFixer: Failed to set link: ' . $e->getMessage());
}
}
} else {
error_log('TelegramLinkFixer: No Telegraph link found in description');
}
} else {
error_log('TelegramLinkFixer: No Telegraph link found in description');
} catch (Exception $e) {
error_log('TelegramLinkFixer: Error processing entry: ' . $e->getMessage());
}
}
}