Skip to content

[9.x] Add missing php extensions in composer#45941

Merged
taylorotwell merged 51 commits into
laravel:9.xfrom
joelharkes:9/suggestions
Feb 6, 2023
Merged

[9.x] Add missing php extensions in composer#45941
taylorotwell merged 51 commits into
laravel:9.xfrom
joelharkes:9/suggestions

Conversation

@joelharkes

Copy link
Copy Markdown
Contributor

Followup: #45848

add missing necessary (for testing) and suggested PHP extensions.

Comment thread composer.json Outdated
@taylorotwell taylorotwell marked this pull request as draft February 3, 2023 14:40
@taylorotwell

Copy link
Copy Markdown
Member

Waiting on @timacdonald review.

@timacdonald

timacdonald commented Feb 3, 2023

Copy link
Copy Markdown
Member

Update: I have done a once over of all sub-package splits and the top level composer. This was actually already on my list to dig into.

ext-json is now baked into PHP from PHP 8.0 on. I have removed references to it across all composer.json files.

Here is how I have approached the decisions made for sub-package spits:

  1. If the extension is required by a driver / adapter it is added to suggests.
  2. If the extension is related to a very isolated functionality that feels options, it is added to suggests (see: signal trapping).
  3. Otherwise added to require.

For the top-level composer.json:

  1. If it is required by a sub-package it is added to required. We might want to do this on feel though, rather than a blanket rule.
  2. If it is optional in a sub-package it is added to suggests

@timacdonald timacdonald self-assigned this Feb 3, 2023
"php": "^8.0.2",
"ext-json": "*",
"ext-filter": "*",
"ext-mbstring": "*",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

protected function getSize($attribute, $value)
{
$hasNumeric = $this->hasRule($attribute, $this->numericRules);
// This method will determine if the attribute is a number, string, or file and
// return the proper size accordingly. If it is a number, then number itself
// is the size. If it is a file, we take kilobytes, and for a string the
// entire length of the string will be considered the attribute size.
if (is_numeric($value) && $hasNumeric) {
return $this->trim($value);
} elseif (is_array($value)) {
return count($value);
} elseif ($value instanceof File) {
return $value->getSize() / 1024;
}
return mb_strlen($value ?? '');
}

protected function addWhere($query, $key, $extraValue)
{
if ($extraValue === 'NULL') {
$query->whereNull($key);
} elseif ($extraValue === 'NOT_NULL') {
$query->whereNotNull($key);
} elseif (str_starts_with($extraValue, '!')) {
$query->where($key, '!=', mb_substr($extraValue, 1));
} else {
$query->where($key, $extraValue);
}
}

"require": {
"php": "^8.0.2",
"ext-json": "*",
"ext-tokenizer": "*",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See usages of token_get_all, T_CLOSE_TAG, T_INLINE_HTML, T_OPEN_TAG, and T_OPEN_TAG_WITH_ECHO.

},
"suggest": {
"ext-PDO": "Required to use the database queue worker.",
"ext-filter": "Required to use the SQS queue worker.",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public function getQueue($queue)
{
$queue = $queue ?: $this->default;
return filter_var($queue, FILTER_VALIDATE_URL) === false
? $this->suffixQueue($queue, $this->suffix)
: $queue;
}

"suggest": {
"ext-PDO": "Required to use the database queue worker.",
"ext-filter": "Required to use the SQS queue worker.",
"ext-mbstring": "Required to use the database failed job providers.",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public function log($connection, $queue, $payload, $exception)
{
$failed_at = Date::now();
$exception = (string) mb_convert_encoding($exception, 'UTF-8');
return $this->getTable()->insertGetId(compact(
'connection', 'queue', 'payload', 'exception', 'failed_at'
));
}

public function log($connection, $queue, $payload, $exception)
{
$this->getTable()->insert([
'uuid' => $uuid = json_decode($payload, true)['uuid'],
'connection' => $connection,
'queue' => $queue,
'payload' => $payload,
'exception' => (string) mb_convert_encoding($exception, 'UTF-8'),
'failed_at' => Date::now(),
]);
return $uuid;
}

@laravel laravel deleted a comment from X-Coder264 Feb 6, 2023
}
},
"suggest": {
"ext-fileinfo": "Required to use the Filesystem class.",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public function mimeType($path)
{
return finfo_file(finfo_open(FILEINFO_MIME_TYPE), $path);
}

"suggest": {
"ext-fileinfo": "Required to use the Filesystem class.",
"ext-ftp": "Required to use the Flysystem FTP driver.",
"ext-hash": "Required to use the Filesystem class.",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public function hash($path, $algorithm = 'md5')
{
return hash_file($algorithm, $path);
}

}
},
"suggest": {
"ext-filter": "Required to use the Postgres database driver.",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

protected function compileJsonContainsKey($column)
{
$segments = explode('->', $column);
$lastSegment = array_pop($segments);
if (filter_var($lastSegment, FILTER_VALIDATE_INT) !== false) {
$i = $lastSegment;
} elseif (preg_match('/\[(-?[0-9]+)\]$/', $lastSegment, $matches)) {
$segments[] = Str::beforeLast($lastSegment, $matches[0]);
$i = $matches[1];
}
$column = str_replace('->>', '->', $this->wrap(implode('->', $segments)));
if (isset($i)) {
return vsprintf('case when %s then %s else false end', [
'jsonb_typeof(('.$column.")::jsonb) = 'array'",
'jsonb_array_length(('.$column.')::jsonb) >= '.($i < 0 ? abs($i) : $i + 1),
]);
}
$key = "'".str_replace("'", "''", $lastSegment)."'";
return 'coalesce(('.$column.')::jsonb ?? '.$key.', false)';
}

protected function wrapJsonPathAttributes($path)
{
$quote = func_num_args() === 2 ? func_get_arg(1) : "'";
return collect($path)->map(function ($attribute) {
return $this->parseJsonPathArrayKeys($attribute);
})->collapse()->map(function ($attribute) use ($quote) {
return filter_var($attribute, FILTER_VALIDATE_INT) !== false
? $attribute
: $quote.$attribute.$quote;
})->all();
}

}
},
"suggest": {
"ext-pcntl": "Required to use signal trapping.",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

protected function initializeSignal($signal)
{
return is_callable($existingHandler = pcntl_signal_get_handler($signal))
? [$existingHandler]
: null;
}

public function unregister()
{
$previousHandlers = $this->previousHandlers;
foreach ($previousHandlers as $signal => $handler) {
if (is_null($handler)) {
pcntl_signal($signal, SIG_DFL);
unset($previousHandlers[$signal]);
}
}
$this->setHandlers($previousHandlers);
}

protected function initializeSignal($signal)
{
return is_callable($existingHandler = pcntl_signal_get_handler($signal))
? [$existingHandler]
: null;
}

}
},
"suggest": {
"ext-filter": "Required to use the DynamoDb cache driver.",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

protected function unserialize($value)
{
if (filter_var($value, FILTER_VALIDATE_INT) !== false) {
return (int) $value;
}
if (is_numeric($value)) {
return (float) $value;
}
return unserialize($value);
}

}
},
"suggest": {
"ext-hash": "Required to use the Ably and Pusher broadcast drivers.",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public function resolveAuthenticatedUser($request)
{
if (! $user = parent::resolveAuthenticatedUser($request)) {
return;
}
if (method_exists($this->pusher, 'authenticateUser')) {
return $this->pusher->authenticateUser($request->socket_id, $user);
}
$settings = $this->pusher->getSettings();
$encodedUser = json_encode($user);
$decodedString = "{$request->socket_id}::user::{$encodedUser}";
$auth = $settings['auth_key'].':'.hash_hmac(
'sha256', $decodedString, $settings['secret']
);
return [
'auth' => $auth,
'user_data' => $encodedUser,
];
}

public function generateAblySignature($channelName, $socketId, $userData = null)
{
return hash_hmac(
'sha256',
sprintf('%s:%s%s', $socketId, $channelName, $userData ? ':'.json_encode($userData) : ''),
$this->getPrivateToken(),
);
}

"require": {
"php": "^8.0.2",
"ext-json": "*",
"ext-pdo": "*",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Search usages of \PDO, \PDOStatement, and \PDOException.

}
},
"suggest": {
"ext-pdo": "Required to use the database queue worker.",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

protected function getLockForPopping()
{
$databaseEngine = $this->database->getPdo()->getAttribute(PDO::ATTR_DRIVER_NAME);
$databaseVersion = $this->database->getConfig('version') ?? $this->database->getPdo()->getAttribute(PDO::ATTR_SERVER_VERSION);
if (Str::of($databaseVersion)->contains('MariaDB')) {
$databaseEngine = 'mariadb';
$databaseVersion = Str::before(Str::after($databaseVersion, '5.5.5-'), '-');
} elseif (Str::of($databaseVersion)->contains(['vitess', 'PlanetScale'])) {
$databaseEngine = 'vitess';
$databaseVersion = Str::before($databaseVersion, '-');
}
if (($databaseEngine === 'mysql' && version_compare($databaseVersion, '8.0.1', '>=')) ||
($databaseEngine === 'mariadb' && version_compare($databaseVersion, '10.6.0', '>=')) ||
($databaseEngine === 'pgsql' && version_compare($databaseVersion, '9.5', '>='))) {
return 'FOR UPDATE SKIP LOCKED';
}
if ($databaseEngine === 'sqlsrv') {
return 'with(rowlock,updlock,readpast)';
}
return true;
}

// cc @X-Coder264

Comment thread composer.json
"illuminate/view": "self.version"
},
"require-dev": {
"ext-gmp": "*",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we still need this in require-dev.

See this PR: #43959

Seems best to leave it as GMP objects have some quirks that this addresses and I can't replicate with standard classes.

Comment thread composer.json
],
"require": {
"php": "^8.0.2",
"ext-ctype": "*",

@timacdonald timacdonald Feb 6, 2023

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required in:

  • illuminate/session
  • illuminate/support

Comment thread composer.json
"require": {
"php": "^8.0.2",
"ext-ctype": "*",
"ext-filter": "*",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required in:

  • illuminate/routing
  • illuminate/validation
  • illuminate/support
  • illuminate/http
  • illuminate/pagination

Optional in:

  • illuminate/queue
  • illuminate/cache
  • illuminate/database

Comment thread composer.json
"php": "^8.0.2",
"ext-ctype": "*",
"ext-filter": "*",
"ext-hash": "*",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required in:

  • illuminate/auth
  • illuminate/routing
  • illuminate/cookie
  • illuminate/encryption

Optional in:

  • illuminate/filesystem
  • illuminate/broadcasting

Comment thread composer.json
"ext-hash": "*",
"ext-mbstring": "*",
"ext-openssl": "*",
"ext-session": "*",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required in:

  • illuminate/session

Comment thread composer.json
"ext-mbstring": "*",
"ext-openssl": "*",
"ext-session": "*",
"ext-tokenizer": "*",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required in:

  • illuminate/view

}
},
"suggest": {
"ext-apcu": "Required to use the APC cache driver.",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the ApcWrapper class.

@taylorotwell taylorotwell marked this pull request as ready for review February 6, 2023 02:52
@taylorotwell taylorotwell merged commit e6846df into laravel:9.x Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants