Problem/Motivation
When we try to reference a YouTube video URL on Media Remote Video form without YouTube process finish, one error to report on Database log is generated but the error message throws an exception to log on database.
Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[HY000]: General error: 1366 Incorrect string value: '\xFF\xD8\xFF\xE0\x00\x10...' for column 'message' at row 1: INSERT INTO "watchdog" ("uid", "type", "message", "variables", "severity", "link", "location", "referer", "hostname", "timestamp") VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9); Array ( [:db_insert_placeholder_0] => 1 [:db_insert_placeholder_1] => media [:db_insert_placeholder_2] => Client error: `GET https://i.ytimg.com/vi/zTXZeHc_93s/hqdefault.jpg` resulted in a `404 Not Found` response: ���JFIF��� !"" (truncated...) [:db_insert_placeholder_3] => a:0:{} [:db_insert_placeholder_4] => 4 [:db_insert_placeholder_5] => [:db_insert_placeholder_6] => https://drupal.site/media-library?_wrapper_format=drupal_ajax&ajax_form=1&hash=Qkg0G8WJcT7LbcUjOp81t1osRKvqWFalkPaQG1YP8ck&media_library_allowed_types%5B0%5D=image&media_library_allowed_types%5Baudio%5D=audio&media_library_allowed_types%5Bdocument%5D=document&media_library_allowed_types%5Bremote_video%5D=remote_video&media_library_allowed_types%5Bvideo%5D=video&media_library_opener_id=media_library.opener.editor&media_library_opener_parameters%5Bfilter_format_id%5D=full_html&media_library_remaining=1&media_library_selected_type=remote_video [:db_insert_placeholder_7] => https://drupal.site/node/add/page [:db_insert_placeholder_8] => 127.0.0.1 [:db_insert_placeholder_9] => 1663630569 ) in Drupal\dblog\Logger\DbLog->log() (line 78 of /app/web/core/modules/dblog/src/Logger/DbLog.php).
Steps to reproduce
- Upload a new video on YouTube.
- Try to refernce on Add Remote video via URL field before YouTube finishes the process.
- Check Database logs to see the message
Proposed resolution
Replace direct error message output by a output string with token replacement.
Before:
$this->logger->warning($e->getMessage());
After:
$this->logger->warning('Failed to video thumbnail file due to "%error".', ['%error' => $e->getMessage()]);
Comments
Comment #3
igor.barato commentedComment #4
anchal_gupta commentedFixed CS Error
Comment #5
wim leersOh, interesting! This seems like an encoding problem, and wrapping it in
FormattableMarkupsolves that. Interesting side-effect, but also totally reasonable and harmless! I like it 🤓Tests are overkill in this case IMO.
Comment #6
alexpottCommitted and pushed c36f03ae2b to 10.1.x and d02fe902da to 10.0.x and 172f01a6a2 to 9.5.x and 85df6364af to 9.4.x. Thanks!
Backported to 9.4.x since this is a useful bugfix. Agree with #5 tests aren't that helpful here.