mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-19 23:32:17 +02:00
migration symfony 5 4 (#300)
* symfony 5.4 (diff dev) * symfony 5.4 (working) * symfony 5.4 (update autoload) * symfony 5.4 (remove swiftmailer mailer implementation) * symfony 5.4 (php doc and split Global accessor class) ### Impacted packages: composer require php:">=7.2.5 <8.0.0" symfony/console:5.4.* symfony/dotenv:5.4.* symfony/framework-bundle:5.4.* symfony/twig-bundle:5.4.* symfony/yaml:5.4.* --update-with-dependencies composer require symfony/stopwatch:5.4.* symfony/web-profiler-bundle:5.4.* --dev --update-with-dependencies
This commit is contained in:
@@ -4,14 +4,14 @@
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Stig Bakken <ssb@php.net>
|
||||
* @author Gregory Beaver <cellog@php.net>
|
||||
* @copyright 1997-2009 The Authors
|
||||
* @license http://opensource.org/licenses/bsd-license.php New BSD License
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since File available since PEAR 0.1
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Stig Bakken <ssb@php.net>
|
||||
* @author Gregory Beaver <cellog@php.net>
|
||||
* @copyright 1997-2009 The Authors
|
||||
* @license http://opensource.org/licenses/bsd-license.php New BSD License
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since File available since PEAR 0.1
|
||||
*/
|
||||
|
||||
// {{{ uname examples
|
||||
@@ -80,15 +80,15 @@
|
||||
*
|
||||
* This class uses php_uname() to grok information about the current OS
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Stig Bakken <ssb@php.net>
|
||||
* @author Gregory Beaver <cellog@php.net>
|
||||
* @copyright 1997-2009 The Authors
|
||||
* @license http://opensource.org/licenses/bsd-license.php New BSD License
|
||||
* @version Release: @package_version@
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since Class available since Release 0.1
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Stig Bakken <ssb@php.net>
|
||||
* @author Gregory Beaver <cellog@php.net>
|
||||
* @copyright 1997-2020 The Authors
|
||||
* @license http://opensource.org/licenses/bsd-license.php New BSD License
|
||||
* @version Release: @package_version@
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since Class available since Release 0.1
|
||||
*/
|
||||
class OS_Guess
|
||||
{
|
||||
@@ -138,13 +138,9 @@ class OS_Guess
|
||||
$release = "$parts[3].$parts[2]";
|
||||
break;
|
||||
case 'Windows' :
|
||||
switch ($parts[1]) {
|
||||
case '95/98':
|
||||
$release = '9x';
|
||||
break;
|
||||
default:
|
||||
$release = $parts[1];
|
||||
break;
|
||||
$release = $parts[1];
|
||||
if ($release == '95/98') {
|
||||
$release = '9x';
|
||||
}
|
||||
$cpu = 'i386';
|
||||
break;
|
||||
@@ -157,18 +153,10 @@ class OS_Guess
|
||||
$sysname = 'darwin';
|
||||
$nodename = $parts[2];
|
||||
$release = $parts[3];
|
||||
if ($cpu == 'Macintosh') {
|
||||
if ($parts[$n - 2] == 'Power') {
|
||||
$cpu = 'powerpc';
|
||||
}
|
||||
}
|
||||
$cpu = $this->_determineIfPowerpc($cpu, $parts);
|
||||
break;
|
||||
case 'Darwin' :
|
||||
if ($cpu == 'Macintosh') {
|
||||
if ($parts[$n - 2] == 'Power') {
|
||||
$cpu = 'powerpc';
|
||||
}
|
||||
}
|
||||
$cpu = $this->_determineIfPowerpc($cpu, $parts);
|
||||
$release = preg_replace('/^([0-9]+\.[0-9]+).*/', '\1', $parts[2]);
|
||||
break;
|
||||
default:
|
||||
@@ -187,6 +175,15 @@ class OS_Guess
|
||||
return array($sysname, $release, $cpu, $extra, $nodename);
|
||||
}
|
||||
|
||||
function _determineIfPowerpc($cpu, $parts)
|
||||
{
|
||||
$n = count($parts);
|
||||
if ($cpu == 'Macintosh' && $parts[$n - 2] == 'Power') {
|
||||
$cpu = 'powerpc';
|
||||
}
|
||||
return $cpu;
|
||||
}
|
||||
|
||||
function _detectGlibcVersion()
|
||||
{
|
||||
static $glibc = false;
|
||||
@@ -196,74 +193,29 @@ class OS_Guess
|
||||
$major = $minor = 0;
|
||||
include_once "System.php";
|
||||
|
||||
if (@is_link('/lib64/libc.so.6')) {
|
||||
// Let's try reading the libc.so.6 symlink
|
||||
if (preg_match('/^libc-(.*)\.so$/', basename(readlink('/lib64/libc.so.6')), $matches)) {
|
||||
list($major, $minor) = explode('.', $matches[1]);
|
||||
}
|
||||
} else if (@is_link('/lib/libc.so.6')) {
|
||||
// Let's try reading the libc.so.6 symlink
|
||||
if (preg_match('/^libc-(.*)\.so$/', basename(readlink('/lib/libc.so.6')), $matches)) {
|
||||
list($major, $minor) = explode('.', $matches[1]);
|
||||
// Let's try reading possible libc.so.6 symlinks
|
||||
$libcs = array(
|
||||
'/lib64/libc.so.6',
|
||||
'/lib/libc.so.6',
|
||||
'/lib/i386-linux-gnu/libc.so.6'
|
||||
);
|
||||
$versions = array();
|
||||
foreach ($libcs as $file) {
|
||||
$versions = $this->_readGlibCVersionFromSymlink($file);
|
||||
if ($versions != []) {
|
||||
list($major, $minor) = $versions;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Use glibc's <features.h> header file to
|
||||
// get major and minor version number:
|
||||
if (!($major && $minor) &&
|
||||
@file_exists('/usr/include/features.h') &&
|
||||
@is_readable('/usr/include/features.h')) {
|
||||
if (!@file_exists('/usr/bin/cpp') || !@is_executable('/usr/bin/cpp')) {
|
||||
$features_file = fopen('/usr/include/features.h', 'rb');
|
||||
while (!feof($features_file)) {
|
||||
$line = fgets($features_file, 8192);
|
||||
if (!$line || (strpos($line, '#define') === false)) {
|
||||
continue;
|
||||
}
|
||||
if (strpos($line, '__GLIBC__')) {
|
||||
// major version number #define __GLIBC__ version
|
||||
$line = preg_split('/\s+/', $line);
|
||||
$glibc_major = trim($line[2]);
|
||||
if (isset($glibc_minor)) {
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strpos($line, '__GLIBC_MINOR__')) {
|
||||
// got the minor version number
|
||||
// #define __GLIBC_MINOR__ version
|
||||
$line = preg_split('/\s+/', $line);
|
||||
$glibc_minor = trim($line[2]);
|
||||
if (isset($glibc_major)) {
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
fclose($features_file);
|
||||
if (!isset($glibc_major) || !isset($glibc_minor)) {
|
||||
return $glibc = '';
|
||||
}
|
||||
return $glibc = 'glibc' . trim($glibc_major) . "." . trim($glibc_minor) ;
|
||||
} // no cpp
|
||||
|
||||
$tmpfile = System::mktemp("glibctest");
|
||||
$fp = fopen($tmpfile, "w");
|
||||
fwrite($fp, "#include <features.h>\n__GLIBC__ __GLIBC_MINOR__\n");
|
||||
fclose($fp);
|
||||
$cpp = popen("/usr/bin/cpp $tmpfile", "r");
|
||||
while ($line = fgets($cpp, 1024)) {
|
||||
if ($line[0] == '#' || trim($line) == '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (list($major, $minor) = explode(' ', trim($line))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
pclose($cpp);
|
||||
unlink($tmpfile);
|
||||
} // features.h
|
||||
if (!($major && $minor)) {
|
||||
$versions = $this->_readGlibCVersionFromFeaturesHeaderFile();
|
||||
}
|
||||
if (is_array($versions) && $versions != []) {
|
||||
list($major, $minor) = $versions;
|
||||
}
|
||||
|
||||
if (!($major && $minor)) {
|
||||
return $glibc = '';
|
||||
@@ -272,6 +224,102 @@ class OS_Guess
|
||||
return $glibc = "glibc{$major}.{$minor}";
|
||||
}
|
||||
|
||||
function _readGlibCVersionFromSymlink($file)
|
||||
{
|
||||
$versions = array();
|
||||
if (@is_link($file)
|
||||
&& (preg_match('/^libc-(.*)\.so$/', basename(readlink($file)), $matches))
|
||||
) {
|
||||
$versions = explode('.', $matches[1]);
|
||||
}
|
||||
return $versions;
|
||||
}
|
||||
|
||||
|
||||
function _readGlibCVersionFromFeaturesHeaderFile()
|
||||
{
|
||||
$features_header_file = '/usr/include/features.h';
|
||||
if (!(@file_exists($features_header_file)
|
||||
&& @is_readable($features_header_file))
|
||||
) {
|
||||
return array();
|
||||
}
|
||||
if (!@file_exists('/usr/bin/cpp') || !@is_executable('/usr/bin/cpp')) {
|
||||
return $this-_parseFeaturesHeaderFile($features_header_file);
|
||||
} // no cpp
|
||||
|
||||
return $this->_fromGlibCTest();
|
||||
}
|
||||
|
||||
function _parseFeaturesHeaderFile($features_header_file)
|
||||
{
|
||||
$features_file = fopen($features_header_file, 'rb');
|
||||
while (!feof($features_file)) {
|
||||
$line = fgets($features_file, 8192);
|
||||
if (!$this->_IsADefinition($line)) {
|
||||
continue;
|
||||
}
|
||||
if (strpos($line, '__GLIBC__')) {
|
||||
// major version number #define __GLIBC__ version
|
||||
$line = preg_split('/\s+/', $line);
|
||||
$glibc_major = trim($line[2]);
|
||||
if (isset($glibc_minor)) {
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strpos($line, '__GLIBC_MINOR__')) {
|
||||
// got the minor version number
|
||||
// #define __GLIBC_MINOR__ version
|
||||
$line = preg_split('/\s+/', $line);
|
||||
$glibc_minor = trim($line[2]);
|
||||
if (isset($glibc_major)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose($features_file);
|
||||
if (!isset($glibc_major) || !isset($glibc_minor)) {
|
||||
return array();
|
||||
}
|
||||
return array(trim($glibc_major), trim($glibc_minor));
|
||||
}
|
||||
|
||||
function _IsADefinition($line)
|
||||
{
|
||||
if ($line === false) {
|
||||
return false;
|
||||
}
|
||||
return strpos(trim($line), '#define') !== false;
|
||||
}
|
||||
|
||||
function _fromGlibCTest()
|
||||
{
|
||||
$major = null;
|
||||
$minor = null;
|
||||
|
||||
$tmpfile = System::mktemp("glibctest");
|
||||
$fp = fopen($tmpfile, "w");
|
||||
fwrite($fp, "#include <features.h>\n__GLIBC__ __GLIBC_MINOR__\n");
|
||||
fclose($fp);
|
||||
$cpp = popen("/usr/bin/cpp $tmpfile", "r");
|
||||
while ($line = fgets($cpp, 1024)) {
|
||||
if ($line[0] == '#' || trim($line) == '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (list($major, $minor) = explode(' ', trim($line))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
pclose($cpp);
|
||||
unlink($tmpfile);
|
||||
if ($major !== null && $minor !== null) {
|
||||
return [$major, $minor];
|
||||
}
|
||||
}
|
||||
|
||||
function getSignature()
|
||||
{
|
||||
if (empty($this->extra)) {
|
||||
@@ -328,12 +376,16 @@ class OS_Guess
|
||||
function _matchFragment($fragment, $value)
|
||||
{
|
||||
if (strcspn($fragment, '*?') < strlen($fragment)) {
|
||||
$reg = '/^' . str_replace(array('*', '?', '/'), array('.*', '.', '\\/'), $fragment) . '\\z/';
|
||||
$expression = str_replace(
|
||||
array('*', '?', '/'),
|
||||
array('.*', '.', '\\/'),
|
||||
$fragment
|
||||
);
|
||||
$reg = '/^' . $expression . '\\z/';
|
||||
return preg_match($reg, $value);
|
||||
}
|
||||
return ($fragment == '*' || !strcasecmp($fragment, $value));
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* Local Variables:
|
||||
|
||||
@@ -530,7 +530,9 @@ class System
|
||||
// It's possible to run a .bat on Windows that is_executable
|
||||
// would return false for. The is_executable check is meaningless...
|
||||
if (OS_WINDOWS) {
|
||||
return $file;
|
||||
if (file_exists($file)) {
|
||||
return $file;
|
||||
}
|
||||
} else {
|
||||
if (is_executable($file)) {
|
||||
return $file;
|
||||
|
||||
Reference in New Issue
Block a user