Azure / azure-storage-php

Microsoft Azure Storage Library for PHP
MIT License
217 stars 198 forks source link

BlobRestProxy::saveBlobToFile fails on PHP 8.1 with Passing null to parameter #1 is deprecated #320

Closed spaze closed 2 years ago

spaze commented 2 years ago

Which service(blob, file, queue, table) does this issue concern?

blob

Which version of the SDK was used?

1.5.3 (current)

What's the PHP/OS version?

PHP 8.1

What problem was encountered?

When calling BlobRestProxy->saveBlobToFile, a wild

strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated

appears. Stack trace below.

Steps to reproduce the issue?

Call BlobRestProxy->saveBlobToFile()

Have you found a mitigation/solution?

Yes, as usual :-) (#321)

The stack trace:

ErrorException: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in vendor/microsoft/azure-storage-blob/src/Blob/Models/CopyState.php:115
Stack trace:
#0 libraries/Tracy/Integration.php(38): Tracy\Debugger::errorHandler(8192, '...', '...', 115)
#1 [internal function]: _error_handler(8192, '...', '...', 115)
#2 vendor/microsoft/azure-storage-blob/src/Blob/Models/CopyState.php(115): strpos(NULL, '...')
#3 vendor/microsoft/azure-storage-blob/src/Blob/Models/BlobProperties.php(160): MicrosoftAzure\Storage\Blob\Models\CopyState::createFromHttpHeaders(Array)
#4 vendor/microsoft/azure-storage-blob/src/Blob/Models/GetBlobResult.php(63): MicrosoftAzure\Storage\Blob\Models\BlobProperties::createFromHttpHeaders(Array)
#5 vendor/microsoft/azure-storage-blob/src/Blob/BlobRestProxy.php(3789): MicrosoftAzure\Storage\Blob\Models\GetBlobResult::create(Array, Object(GuzzleHttp\Psr7\Stream), Array)
#6 vendor/guzzlehttp/promises/src/Promise.php(204): MicrosoftAzure\Storage\Blob\BlobRestProxy->MicrosoftAzure\Storage\Blob\{closure}(Object(GuzzleHttp\Psr7\Response))
#7 vendor/guzzlehttp/promises/src/Promise.php(153): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), NULL)
#8 vendor/guzzlehttp/promises/src/TaskQueue.php(48): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}()
#9 vendor/guzzlehttp/promises/src/Promise.php(248): GuzzleHttp\Promise\TaskQueue->run(true)
#10 vendor/guzzlehttp/promises/src/Promise.php(224): GuzzleHttp\Promise\Promise->invokeWaitFn()
#11 vendor/guzzlehttp/promises/src/Promise.php(269): GuzzleHttp\Promise\Promise->waitIfPending()
#12 vendor/guzzlehttp/promises/src/Promise.php(226): GuzzleHttp\Promise\Promise->invokeWaitList()
#13 vendor/guzzlehttp/promises/src/Promise.php(62): GuzzleHttp\Promise\Promise->waitIfPending()
#14 vendor/microsoft/azure-storage-blob/src/Blob/BlobRestProxy.php(3645): GuzzleHttp\Promise\Promise->wait()
#15 application/libraries/Report/Email/Attachment.php(100): MicrosoftAzure\Storage\Blob\BlobRestProxy->saveBlobToFile('...', '...', '...')
paaaaaaaaaa commented 2 years ago

I was receiving this error when calling on a BlobRestProxy->getBlob() a quick and dirty resolution whilst we wait for an the fix to be merged is to suppress the error with the at symbol. You can still catch exceptions if a file is not found. @BlobRestProxy->getBlob()