Fixed a bug that Utilities::allZero() will return true for non-zero data chunks.
This commit is contained in:
Родитель
01d96448f6
Коммит
9bd52d46f2
|
@ -11,6 +11,7 @@ All
|
|||
* Moved method `SharedAccessSignatureHelper::generateFileServiceSharedAccessSignatureToken()` into `FileSharedAccessSignatureHelper`.
|
||||
* `CommonMiddleWare` constructor requires storage service version as parameter now.
|
||||
* `AccessPolicy` class is now an abstract class, added children classes `BlobAccessPolicy`, `ContainerAccessPolicy`, `TableAccessPolicy`, `QueueAccessPolicy`, `FileAccessPolicy` and `ShareAccessPolicy`.
|
||||
* Fixed a bug that `Utilities::allZero()` will return true for non-zero data chunks.
|
||||
* Deprecated PHP 5.5 support.
|
||||
|
||||
Blob
|
||||
|
|
|
@ -7,4 +7,5 @@
|
|||
* Moved method `SharedAccessSignatureHelper::generateFileServiceSharedAccessSignatureToken()` into `FileSharedAccessSignatureHelper`.
|
||||
* `CommonMiddleWare` constructor requires storage service version as parameter now.
|
||||
* `AccessPolicy` class is now an abstract class, added children classes `BlobAccessPolicy`, `ContainerAccessPolicy`, `TableAccessPolicy`, `QueueAccessPolicy`, `FileAccessPolicy` and `ShareAccessPolicy`.
|
||||
* Fixed a bug that `Utilities::allZero()` will return true for non-zero data chunks.
|
||||
* Deprecated PHP 5.5 support.
|
|
@ -783,7 +783,9 @@ class Utilities
|
|||
|
||||
/**
|
||||
* Check if all the bytes are zero.
|
||||
*
|
||||
* @param string $content The content.
|
||||
* @return bool
|
||||
*/
|
||||
public static function allZero($content)
|
||||
{
|
||||
|
@ -791,7 +793,7 @@ class Utilities
|
|||
|
||||
// If all Zero, skip this range
|
||||
for ($i = 0; $i < $size; $i++) {
|
||||
if (ord($content[$i] != 0)) {
|
||||
if (ord($content[$i]) != 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ require_once "../vendor/autoload.php";
|
|||
|
||||
use MicrosoftAzure\Storage\Blob\BlobRestProxy;
|
||||
use MicrosoftAzure\Storage\Blob\BlobSharedAccessSignatureHelper;
|
||||
use MicrosoftAzure\Storage\Blob\Models\CreateBlockBlobOptions;
|
||||
use MicrosoftAzure\Storage\Blob\Models\CreateContainerOptions;
|
||||
use MicrosoftAzure\Storage\Blob\Models\PublicAccessType;
|
||||
use MicrosoftAzure\Storage\Blob\Models\DeleteBlobOptions;
|
||||
|
@ -370,7 +371,7 @@ function generateBlobDownloadLinkWithSAS()
|
|||
Resources::RESOURCE_TYPE_BLOB,
|
||||
'mycontainer/myblob',
|
||||
'r', // Read
|
||||
'2018-01-01T08:30:00Z'//, // A valid ISO 8601 format expiry time
|
||||
'2019-01-01T08:30:00Z'//, // A valid ISO 8601 format expiry time
|
||||
//'2016-01-01T08:30:00Z', // A valid ISO 8601 format expiry time
|
||||
//'0.0.0.0-255.255.255.255'
|
||||
//'https,http'
|
||||
|
@ -610,7 +611,7 @@ function leaseOperations($blobClient)
|
|||
$blob = 'Blob' . generateRandomString();
|
||||
echo "Create blob " . $blob . PHP_EOL;
|
||||
$contentType = 'text/plain; charset=UTF-8';
|
||||
$options = new CreateBlobOptions();
|
||||
$options = new CreateBlockBlobOptions();
|
||||
$options->setContentType($contentType);
|
||||
$blobClient->createBlockBlob($container, $blob, 'Hello world', $options);
|
||||
|
||||
|
|
|
@ -1728,7 +1728,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase
|
|||
// Setup
|
||||
$sourceContainerName = 'copyblobincrementalsource' . $this->createSuffix();
|
||||
$sourceBlobName = 'sourceblob';
|
||||
$sourceContentLength = 1024 * 1024 * 8;
|
||||
$sourceContentLength = 512 * 8;
|
||||
$sourceBlobContent = openssl_random_pseudo_bytes($sourceContentLength);
|
||||
|
||||
$destinationContainerName = 'copyblobincrementaldest' . $this->createSuffix();
|
||||
|
|
|
@ -244,6 +244,19 @@ class UtilitiesTest extends \PHPUnit_Framework_TestCase
|
|||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
public function testAllZero()
|
||||
{
|
||||
$this->assertFalse(Utilities::allZero('hello'));
|
||||
|
||||
for ($i = 1; $i < 256; $i++) {
|
||||
$this->assertFalse(Utilities::allZero(pack('c', $i)));
|
||||
}
|
||||
|
||||
$this->assertTrue(Utilities::allZero(pack('c', 0)));
|
||||
|
||||
$this->assertTrue(Utilities::allZero(''));
|
||||
}
|
||||
|
||||
public function testToBoolean()
|
||||
{
|
||||
$this->assertTrue(is_bool(Utilities::toBoolean('true')));
|
||||
|
|
Загрузка…
Ссылка в новой задаче