Azure/azure-storage-php

PHP Fatal error: Uncaught Error: Call to undefined function MicrosoftAzure\Storage\Common\Internal\ctype_space()

Opened this issue · 0 comments

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

Blob

Which version of the SDK was used?

1.5.1 (see below, I've tried all versions)

What's the PHP/OS version?

PHP 7.3.7 - Cygwin - Windows 10

What problem was encountered?

php index.php
PHP Fatal error:  Uncaught Error: Call to undefined function MicrosoftAzure\Storage\Common\Internal\ctype_space() in ./vendor/microsoft/azure-storage-common/src/Common/Internal/ConnectionStringParser.php:194
Stack trace:
#0 ./vendor/microsoft/azure-storage-common/src/Common/Internal/ConnectionStringParser.php(101): MicrosoftAzure\Storage\Common\Internal\ConnectionStringParser->_skipWhiteSpaces()
#1 ./vendor/microsoft/azure-storage-common/src/Common/Internal/ConnectionStringParser.php(69): MicrosoftAzure\Storage\Common\Internal\ConnectionStringParser->_parse()
#2 ./vendor/microsoft/azure-storage-common/src/Common/Internal/ServiceSettings.php(85): MicrosoftAzure\Storage\Common\Internal\ConnectionStringParser::parseConnectionString('connectionStrin...', 'DefaultEndpoint...')
#3 ./vendor/microsoft/azure-storage-common/src/Common/Internal/StorageServiceSettings.php(369): MicrosoftAzure\Storage\Common\Internal\ServiceSettings::parseAndValidateKeys('DefaultEnd in ./vendor/microsoft/azure-storage-common/src/Common/Internal/ConnectionStringParser.php on line 194

Steps to reproduce the issue?

<?php

require 'vendor/autoload.php';

use MicrosoftAzure\Storage\Blob\BlobRestProxy;

$connectionString = "<connection string from Azure Portal>"

$blobClient = BlobRestProxy::createBlobService($connectionString);

The error is found here: https://github.com/Azure/azure-storage-php/blob/master/azure-storage-common/src/Common/Internal/ConnectionStringParser.php#L194

I've tried all versions listed on packagist including dev-master
image
All of them produce the same error.

My connection string contains no spaces.

Have you found a mitigation/solution?

No, it seems the ctype extension is needed but not listed on the README as a required extension... https://www.php.net/manual/en/ref.ctype.php

EDIT: Partial Mitigation is to implement ctype_space in userland:
EDIT2: Added function_exists checking.

if (! function_exists('ctype_space'))
{
	function ctype_space($text) : bool
	{
		return preg_match('%^\s+$%', $text) === 1;
	}
}

See here:
https://github.com/Azure/azure-storage-php#minimum-requirements

Is there a failing request ID related to this problem returned by server? What is it?

N/A

What is the storage account name and time frame of your last reproduce? (UTC YYYY/MM/DD hh:mm:ss)

N/A