mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 20:01:06 +07:00
Add support to remove all shared extensions
This commit is contained in:
parent
4beeea41b4
commit
b2d037d560
@ -3,10 +3,11 @@ import * as extensions from '../src/extensions';
|
||||
describe('Extension tests', () => {
|
||||
it('checking addExtensionOnWindows', async () => {
|
||||
let win32: string = await extensions.addExtension(
|
||||
'Xdebug, pcov, sqlite, :intl, phalcon4, pecl_http, ioncube, oci8, pdo_oci, ast-beta, grpc-1.2.3, inotify-1.2.3alpha2, sqlsrv-1.2.3preview1',
|
||||
'none, Xdebug, pcov, sqlite, :intl, phalcon4, pecl_http, ioncube, oci8, pdo_oci, ast-beta, grpc-1.2.3, inotify-1.2.3alpha2, sqlsrv-1.2.3preview1',
|
||||
'7.4',
|
||||
'win32'
|
||||
);
|
||||
expect(win32).toContain('Disable-AllShared');
|
||||
expect(win32).toContain('Add-Extension xdebug');
|
||||
expect(win32).toContain('Add-Extension pcov');
|
||||
expect(win32).toContain('Add-Extension sqlite3');
|
||||
@ -72,10 +73,11 @@ describe('Extension tests', () => {
|
||||
|
||||
it('checking addExtensionOnLinux', async () => {
|
||||
let linux: string = await extensions.addExtension(
|
||||
'Xdebug, pcov, sqlite, :intl, ast, ast-beta, pdo_mysql, pdo-odbc, xdebug-alpha, grpc-1.2.3',
|
||||
'none, Xdebug, pcov, sqlite, :intl, ast, ast-beta, pdo_mysql, pdo-odbc, xdebug-alpha, grpc-1.2.3',
|
||||
'7.4',
|
||||
'linux'
|
||||
);
|
||||
expect(linux).toContain('disable_all_shared');
|
||||
expect(linux).toContain('add_extension xdebug');
|
||||
expect(linux).toContain('add_extension sqlite3');
|
||||
expect(linux).toContain('disable_extension intl');
|
||||
@ -160,10 +162,11 @@ describe('Extension tests', () => {
|
||||
|
||||
it('checking addExtensionOnDarwin', async () => {
|
||||
let darwin: string = await extensions.addExtension(
|
||||
'amqp, apcu, Xdebug, pcov, grpc, igbinary, imagick, imap, memcache, memcached, mongodb, msgpack, phalcon3, phalcon4, protobuf, psr, rdkafka, redis, swoole, yaml, sqlite, oci8, pdo_oci, :intl, ast-beta, grpc-1.2.3',
|
||||
'none, amqp, apcu, Xdebug, pcov, grpc, igbinary, imagick, imap, memcache, memcached, mongodb, msgpack, phalcon3, phalcon4, protobuf, psr, rdkafka, redis, swoole, yaml, sqlite, oci8, pdo_oci, :intl, ast-beta, grpc-1.2.3',
|
||||
'7.2',
|
||||
'darwin'
|
||||
);
|
||||
expect(darwin).toContain('disable_all_shared');
|
||||
expect(darwin).toContain('add_brew_extension amqp extension');
|
||||
expect(darwin).toContain('add_brew_extension apcu extension');
|
||||
expect(darwin).toContain('add_brew_extension xdebug zend_extension');
|
||||
|
@ -127,8 +127,8 @@ describe('Utils tests', () => {
|
||||
|
||||
it('checking extensionArray', async () => {
|
||||
expect(
|
||||
await utils.extensionArray('a, :b, php_c, php-d, Zend e, :Zend f')
|
||||
).toEqual(['a', ':b', 'c', 'd', 'e', ':f']);
|
||||
await utils.extensionArray('a, :b, php_c, none, php-d, Zend e, :Zend f')
|
||||
).toEqual(['none', 'a', ':b', 'c', 'd', 'e', ':f']);
|
||||
|
||||
expect(await utils.extensionArray('')).toEqual([]);
|
||||
expect(await utils.extensionArray(' ')).toEqual([]);
|
||||
|
35
dist/index.js
vendored
35
dist/index.js
vendored
@ -212,6 +212,9 @@ async function addExtensionDarwin(extension_csv, version) {
|
||||
case /^:/.test(ext_name):
|
||||
remove_script += '\ndisable_extension' + ext_name.replace(/:/g, ' ');
|
||||
return;
|
||||
case /^none$/.test(ext_name):
|
||||
add_script += '\ndisable_all_shared';
|
||||
return;
|
||||
case /.+-.+\/.+@.+/.test(extension):
|
||||
add_script += await utils.parseExtensionSource(extension, ext_prefix);
|
||||
return;
|
||||
@ -258,6 +261,9 @@ async function addExtensionWindows(extension_csv, version) {
|
||||
case /^:/.test(ext_name):
|
||||
remove_script += '\nDisable-Extension' + ext_name.replace(/:/g, ' ');
|
||||
break;
|
||||
case /^none$/.test(ext_name):
|
||||
add_script += '\nDisable-AllShared';
|
||||
break;
|
||||
case /^(5\.[3-6]|7\.[0-4]|8\.0)blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension):
|
||||
case /^pdo_oci$|^oci8$|^pdo_firebird$/.test(extension):
|
||||
case /^(5\.[3-6]|7\.[0-4])ioncube$/.test(version_extension):
|
||||
@ -315,6 +321,9 @@ async function addExtensionLinux(extension_csv, version) {
|
||||
case /^:/.test(ext_name):
|
||||
remove_script += '\ndisable_extension' + ext_name.replace(/:/g, ' ');
|
||||
return;
|
||||
case /^none$/.test(ext_name):
|
||||
add_script += '\ndisable_all_shared';
|
||||
return;
|
||||
case /.+-.+\/.+@.+/.test(extension):
|
||||
add_script += await utils.parseExtensionSource(extension, ext_prefix);
|
||||
return;
|
||||
@ -1041,18 +1050,20 @@ async function extensionArray(extension_csv) {
|
||||
case ' ':
|
||||
return [];
|
||||
default:
|
||||
return extension_csv
|
||||
.split(',')
|
||||
.map(function (extension) {
|
||||
if (/.+-.+\/.+@.+/.test(extension)) {
|
||||
return extension;
|
||||
}
|
||||
return extension
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
.replace(/^(:)?(php[-_]|zend )/, '$1');
|
||||
})
|
||||
.filter(Boolean);
|
||||
return [
|
||||
extension_csv.match(/(^|,\s?)none(\s?,|$)/) ? 'none' : '',
|
||||
...extension_csv
|
||||
.split(',')
|
||||
.map(function (extension) {
|
||||
if (/.+-.+\/.+@.+/.test(extension)) {
|
||||
return extension;
|
||||
}
|
||||
return extension
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
.replace(/^(:)?(php[-_]|none|zend )/, '$1');
|
||||
})
|
||||
].filter(Boolean);
|
||||
}
|
||||
}
|
||||
exports.extensionArray = extensionArray;
|
||||
|
@ -23,6 +23,10 @@ export async function addExtensionDarwin(
|
||||
case /^:/.test(ext_name):
|
||||
remove_script += '\ndisable_extension' + ext_name.replace(/:/g, ' ');
|
||||
return;
|
||||
// Match none
|
||||
case /^none$/.test(ext_name):
|
||||
add_script += '\ndisable_all_shared';
|
||||
return;
|
||||
// match extensions for compiling from source
|
||||
case /.+-.+\/.+@.+/.test(extension):
|
||||
add_script += await utils.parseExtensionSource(extension, ext_prefix);
|
||||
@ -117,6 +121,10 @@ export async function addExtensionWindows(
|
||||
case /^:/.test(ext_name):
|
||||
remove_script += '\nDisable-Extension' + ext_name.replace(/:/g, ' ');
|
||||
break;
|
||||
// Match none
|
||||
case /^none$/.test(ext_name):
|
||||
add_script += '\nDisable-AllShared';
|
||||
break;
|
||||
// match 5.3blackfire...8.0blackfire
|
||||
// match 5.3blackfire-(semver)...8.0blackfire-(semver)
|
||||
// match pdo_oci and oci8
|
||||
@ -229,6 +237,10 @@ export async function addExtensionLinux(
|
||||
case /^:/.test(ext_name):
|
||||
remove_script += '\ndisable_extension' + ext_name.replace(/:/g, ' ');
|
||||
return;
|
||||
// Match none
|
||||
case /^none$/.test(ext_name):
|
||||
add_script += '\ndisable_all_shared';
|
||||
return;
|
||||
// match extensions for compiling from source
|
||||
case /.+-.+\/.+@.+/.test(extension):
|
||||
add_script += await utils.parseExtensionSource(extension, ext_prefix);
|
||||
|
@ -183,6 +183,13 @@ disable_extension() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to disable shared extensions.
|
||||
disable_all_shared() {
|
||||
sudo sed -i.orig -E -e "/^(zend_)?extension\s*=/d" "${ini_file[@]}" "$pecl_file" 2>/dev/null || true
|
||||
sudo find "${ini_dir:-$scan_dir}"/.. -name "*.ini" -not -path "*php.ini" -not -path "*mods-available*" -delete >/dev/null 2>&1 || true
|
||||
add_log "${tick:?}" "none" "Disabled all shared extensions"
|
||||
}
|
||||
|
||||
# Function to configure PHP
|
||||
configure_php() {
|
||||
(
|
||||
|
@ -307,6 +307,12 @@ Function Disable-Extension() {
|
||||
}
|
||||
}
|
||||
|
||||
# Function to disable shared extensions.
|
||||
Function Disable-AllShared() {
|
||||
(Get-Content $php_dir\php.ini) | Where-Object {$_ -notmatch '^(zend_)?extension\s*='} | Set-Content $php_dir\php.ini
|
||||
Add-Log $tick "none" "Disabled all shared extensions"
|
||||
}
|
||||
|
||||
# Function to configure composer.
|
||||
Function Edit-ComposerConfig() {
|
||||
Param(
|
||||
|
27
src/utils.ts
27
src/utils.ts
@ -280,18 +280,21 @@ export async function extensionArray(
|
||||
case ' ':
|
||||
return [];
|
||||
default:
|
||||
return extension_csv
|
||||
.split(',')
|
||||
.map(function (extension: string) {
|
||||
if (/.+-.+\/.+@.+/.test(extension)) {
|
||||
return extension;
|
||||
}
|
||||
return extension
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
.replace(/^(:)?(php[-_]|zend )/, '$1');
|
||||
})
|
||||
.filter(Boolean);
|
||||
return [
|
||||
extension_csv.match(/(^|,\s?)none(\s?,|$)/) ? 'none' : '',
|
||||
...extension_csv
|
||||
.split(',')
|
||||
|
||||
.map(function (extension: string) {
|
||||
if (/.+-.+\/.+@.+/.test(extension)) {
|
||||
return extension;
|
||||
}
|
||||
return extension
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
.replace(/^(:)?(php[-_]|none|zend )/, '$1');
|
||||
})
|
||||
].filter(Boolean);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user