Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 51 commits into from
Feb 6, 2023

Conversation

joelharkes
Copy link
Contributor

Followup: #45848

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

composer.json Outdated Show resolved Hide resolved
@taylorotwell taylorotwell marked this pull request as draft February 3, 2023 14:40
@taylorotwell
Copy link
Member

Waiting on @timacdonald review.

@timacdonald
Copy link
Member

timacdonald commented Feb 3, 2023

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
@@ -15,7 +15,8 @@
],
"require": {
"php": "^8.0.2",
"ext-json": "*",
"ext-filter": "*",
"ext-mbstring": "*",
Copy link
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);
}
}

@@ -15,7 +15,7 @@
],
"require": {
"php": "^8.0.2",
"ext-json": "*",
"ext-tokenizer": "*",
Copy link
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.

@@ -39,6 +38,9 @@
}
},
"suggest": {
"ext-PDO": "Required to use the database queue worker.",
"ext-filter": "Required to use the SQS queue worker.",
Copy link
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;
}

@@ -39,6 +38,9 @@
}
},
"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
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
@@ -32,7 +32,9 @@
}
},
"suggest": {
"ext-fileinfo": "Required to use the Filesystem class.",
Copy link
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);
}

"ext-ftp": "Required to use the Flysystem FTP driver.",
"ext-hash": "Required to use the Filesystem class.",
Copy link
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);
}

@@ -36,6 +36,7 @@
}
},
"suggest": {
"ext-filter": "Required to use the Postgres database driver.",
Copy link
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();
}

@@ -35,6 +36,7 @@
}
},
"suggest": {
"ext-pcntl": "Required to use signal trapping.",
Copy link
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;
}

@@ -34,6 +34,7 @@
}
},
"suggest": {
"ext-filter": "Required to use the DynamoDb cache driver.",
Copy link
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);
}

@@ -35,6 +34,7 @@
}
},
"suggest": {
"ext-hash": "Required to use the Ably and Pusher broadcast drivers.",
Copy link
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(),
);
}

@@ -16,7 +16,7 @@
],
"require": {
"php": "^8.0.2",
"ext-json": "*",
"ext-pdo": "*",
Copy link
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.

@@ -39,6 +38,9 @@
}
},
"suggest": {
"ext-pdo": "Required to use the database queue worker.",
Copy link
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

@@ -83,6 +88,7 @@
"illuminate/view": "self.version"
},
"require-dev": {
"ext-gmp": "*",
Copy link
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.

@@ -16,8 +16,13 @@
],
"require": {
"php": "^8.0.2",
"ext-ctype": "*",
Copy link
Member

@timacdonald timacdonald Feb 6, 2023

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

@@ -16,8 +16,13 @@
],
"require": {
"php": "^8.0.2",
"ext-ctype": "*",
"ext-filter": "*",
Copy link
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

@@ -16,8 +16,13 @@
],
"require": {
"php": "^8.0.2",
"ext-ctype": "*",
"ext-filter": "*",
"ext-hash": "*",
Copy link
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

"ext-mbstring": "*",
"ext-openssl": "*",
"ext-session": "*",
Copy link
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

"ext-mbstring": "*",
"ext-openssl": "*",
"ext-session": "*",
"ext-tokenizer": "*",
Copy link
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

@@ -34,6 +34,8 @@
}
},
"suggest": {
"ext-apcu": "Required to use the APC cache driver.",
Copy link
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