fix: YouTubeFeedExpanderBridge getIcon() null pointer and performance#5011
Open
thrawn-sh wants to merge 1 commit into
Open
fix: YouTubeFeedExpanderBridge getIcon() null pointer and performance#5011thrawn-sh wants to merge 1 commit into
thrawn-sh wants to merge 1 commit into
Conversation
getIcon() had two issues: 1. Null pointer exception: The find() call for [itemprop="thumbnailUrl"] can return null when the element is not present on the page, causing a fatal error when accessing ->href on the result. 2. Unnecessary HTML fetching: Every call to getIcon() fetched and parsed the full YouTube channel HTML page just to extract the icon URL. On instances with a higher number of YouTube feeds, this causes throttling or outright blocking by YouTube, since each feed triggers a full page load solely to resolve the channel icon. Fix the null pointer by checking the find() result before accessing its property, falling back to the parent FeedExpander::getIcon() which returns the generic YouTube favicon. Cache the resolved icon URL via loadCacheValue/saveCacheValue (24h TTL) so subsequent requests return the cached string directly without fetching the channel page, significantly reducing the number of requests made to YouTube. Add dedicated test coverage for parseItem(), hideshorts filtering, embed/nocookie URL handling, and the getIcon() caching and fallback behavior.
Pull request artifacts
last change: Wednesday 2026-06-24 06:29:28 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
getIcon() had two issues:
Null pointer exception: The find() call for [itemprop="thumbnailUrl"] can return null when the element is not present on the page, causing a fatal error when accessing ->href on the result.
Unnecessary HTML fetching: Every call to getIcon() fetched and parsed the full YouTube channel HTML page just to extract the icon URL. On instances with a higher number of YouTube feeds, this causes throttling or outright blocking by YouTube, since each feed triggers a full page load solely to resolve the channel icon.
Fix the null pointer by checking the find() result before accessing its property, falling back to the parent FeedExpander::getIcon() which returns the generic YouTube favicon.
Cache the resolved icon URL via loadCacheValue/saveCacheValue (24h TTL) so subsequent requests return the cached string directly without fetching the channel page, significantly reducing the number of requests made to YouTube.
Add dedicated test coverage for parseItem(), hideshorts filtering, embed/nocookie URL handling, and the getIcon() caching and fallback behavior.