Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm not sure how or why this is triggered, but the line 174 "$uri = media_parse_to_uri($video['link'][0]['@attributes']['href']);", is invalid at times. Triggered when clicking Apply when adding media to a field via YouTube tab.
Some of the videos in this loop were:
tag:youtube.com,2008:video:C0DPdy98e4c
2007-02-21T10:27:09.000Z
instead of arrays. Some arrays did not have the link delta structure either.
My workaround was:
if (is_array($video['link']) && is_array($video['link'][0]) && !is_array($video['link'][0]['@attributes']['href'])) {
$uri = media_parse_to_uri($video['link'][0]['@attributes']['href']);
}
Comment | File | Size | Author |
---|---|---|---|
#10 | media_youtube-string-as-array-1668950-10.patch | 657 bytes | aaron |
#5 | media_youtube-string_as_array-1668950-5.patch | 668 bytes | rooby |
Comments
Comment #1
HongPong CreditAttribution: HongPong commentedHmm... with this version of media youtube & media 7.x-2.0-unstable6 had this error when I tried to add youtube urls via what I thought was the correct method.
for "Enabled browser plugins" on the field, just setting Youtube does not work. I set "web" as well.
That provides 2 tabs, a youtube tab and a web tab in the field editor:
The input web URL works right but trying to put the youtube id "ABC123abc123" type code in the youtube tab gives me the string offset error.
Comment #2
RobW CreditAttribution: RobW commentedComment #3
realityloophas there been any solutions found for this issue?
Comment #4
Countzero CreditAttribution: Countzero commentedSame here using latest dev and latest Media dev.
Also, the popup doesn't close itself but loads a page when I happen to make it work, and it never saves the info correctly.
Comment #5
rooby CreditAttribution: rooby commentedThe problem is that the code is expecting an array of results, so if you only get a single result it fails (the response is structured differently for a single result).
This patch fixes it for me.
Comment #6
rooby CreditAttribution: rooby commentedI still cannot actually select a video though.
I know I have successfully used this module in the past so there must be some regressions.
[EDIT] actually it is working now. I will keep an eye out for that issue returning again.
Comment #7
Countzero CreditAttribution: Countzero commentedThe patch definitely solves he Youtube related bug. I can now paste a URL in the textfild, apply, and the video is added.
Still, the popup doesn't close correctly, but I guess it's not related.
Thanks a lot for this patch.
Comment #8
rooby CreditAttribution: rooby commented@Countzero:
I have also seens that popup problem a few times, but currently it is working for me so I cannot investigate further right now.
That probably needs a new issue.
Comment #9
andypostGot the same trouble with current (new stable) version.
Patch solves the critical bug
use isset() against array functions
Comment #10
aaron CreditAttribution: aaron commentedHere is a patch with andypost's suggestion. Because it's so minor and works, I am setting the status to RTBC.
Comment #11
andypost@aaron Thanx a lot! +1 to commit
Comment #12
rooby CreditAttribution: rooby commentedThanks Aaron. I was planning to do that but you saved me the time :)
Comment #13
MurzThis patch fix problem for me, +1 for commit.
Comment #14
sirtetFor me too, this fixes the fatal...
but what i see is that an url like
http://www.youtube.com/watch?v=MWu4J0GY-Kg&feature=c4-overview&list=UUE2...
leads to no results.
only after cutting down to
http://www.youtube.com/watch?v=MWu4J0GY-Kg
it actually finds the video...
Comment #15
AdamGerthel CreditAttribution: AdamGerthel commentedThe patch didn't work at all for me. It solves the fatal error, but when picking a video, the "default" is a file link, not the video itself. It's also difficult to pick the video itself. After searching for the URL, I get thrown back to the upload tab. Going back to the internet tab shows the video I searched for, but the interface looks a bit weird. After selecting the video and then hitting submit I aren't able to pick any other display format than "default" which seems to be broken.
Comment #16
rooby CreditAttribution: rooby commentedI think that this should be committed and new issues opened for all the other propblems people are seeing.
This issue is for
The patch fixes that issue.
If you are seeing different issues than the title of this issue please open a new issue if there isn't one for that specific problem.
Comment #17
botris+1 for commit
Comment #18
axe312 CreditAttribution: axe312 commentedPatch is still applying to current dev after half a year, please commit it!
Comment #19
MurzI have test this patch, it works well, please commit!
Comment #20
aaron CreditAttribution: aaron commentedCommitted to http://drupalcode.org/project/media_youtube.git/commit/df63674.
Comment #22
belvedere CreditAttribution: belvedere commented+1 for patch working
Comment #23
galayant CreditAttribution: galayant commentedHello,
Do you know if this patch (media_youtube-string-as-array-1668950-10.patch) is included in the 2.0-rc5 stable version?
Thanks