Reputation: 73
We have used the YouTube Data API for several years to upload videos to our channels, however as of yesterday I am now getting this error.
Call to undefined method Google\Service\YouTube\Video::getHeaderLine()
Our upload code hasn't changed in months, and we haven't deployed any new versions of our system in a while, so the vendor code in place is unchanged.
This is the code that calls the upload service (i didn't write this but am in the process of writing a new version so its possible this code is out of date with what it should be doing)
$media = new Google_Http_MediaFileUpload($client, $request, $mimeType, null, true, $chunkSizeBytes);
$media->setFileSize(filesize($filePath));
// Read the media file and upload it chunk by chunk.
$status = false;
$handle = fopen($filePath, "rb");
while (!$status && !feof($handle)) {
$chunk = fread($handle, $chunkSizeBytes);
$status = $media->nextChunk($chunk);
}
fclose($handle);
return $status;
This is a partial stack trace from the moment that the video upload process starts
Call to undefined method Google\Service\YouTube\Video::getHeaderLine()
{"file":"/var/www/release/20220602115951/vendor/google/apiclient/src/Http/MediaFileUpload.php","line":310,"code":0,"trace":[{"file":"/var/www/release/20220602115951/vendor/google/apiclient/src/Http/MediaFileUpload.php","line":289,"function":"fetchResumeUri","class":"Google\\Http\\MediaFileUpload"},
{"file":"/var/www/release/20220602115951/vendor/google/apiclient/src/Http/MediaFileUpload.php","line":126,"function":"getResumeUri","class":"Google\\Http\\MediaFileUpload"},
{"file":"/var/www/release/20220602115951/modules/you_tube/src/Services/YouTube.php","line":93,"function":"nextChunk","class":"Google\\Http\\MediaFileUpload"},
{"file":"/var/www/release/20220602115951/modules/you_tube/src/Services/YouTube.php","line":573,"function":"uploadVideoFile","class":"YouTube\\Services\\YouTube"}
Any help would be appreciated
Upvotes: 1
Views: 326
Reputation: 73
This turned out to be an issue introduced in 2.12.5
Line 309 in MediaFileUpload.php has
$response = $this->client->execute($this->request, null);
This line should be
$response = $this->client->execute($this->request, false);
Passing false instead of null is the correct behaviour as line 159 in Http/REST.php would prevent the error being thrown
if (false === $expectedClass) {
It doesn't appear as though a patch has been released yet (as of 6:59am on 6th of June 2022 BST)
So either a manual change to line 309 in MediaFileUpload.php to change the null value to false, will resolve the issue or reverting the google api client back to 2.12.4 would also resolve the issue.
Upvotes: 1