Update PHP version handling to include PHP 8.6 across scripts

- Added PHP 8.6 to the list of system PHP versions and fallback versions in PHPManager.
- Updated return values to include PHP 8.6 in case of errors or empty results.
- Enhanced phpUtilities to recognize PHP 8.6 for CentOS and Ubuntu configurations.
- Adjusted recommended PHP version order to prioritize PHP 8.6.
This commit is contained in:
Master3395
2025-10-16 22:43:12 +02:00
parent 05bcb46fd6
commit cef0192af6
2 changed files with 13 additions and 17 deletions

View File

@@ -58,7 +58,7 @@ class PHPManager:
# Method 2: Check system-wide PHP installations
try:
# Check for system PHP versions
system_php_versions = ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']
system_php_versions = ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5', '8.6']
for version in system_php_versions:
formatted_version = f'PHP {version}'
if formatted_version not in finalPHPVersions:
@@ -117,7 +117,7 @@ class PHPManager:
# Method 4: Fallback to checking common PHP versions
if not finalPHPVersions:
fallback_versions = ['PHP 7.4', 'PHP 8.0', 'PHP 8.1', 'PHP 8.2', 'PHP 8.3', 'PHP 8.4', 'PHP 8.5']
fallback_versions = ['PHP 7.4', 'PHP 8.0', 'PHP 8.1', 'PHP 8.2', 'PHP 8.3', 'PHP 8.4', 'PHP 8.5', 'PHP 8.6']
for version in fallback_versions:
try:
phpString = PHPManager.getPHPString(version)
@@ -145,25 +145,18 @@ class PHPManager:
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
logging.writeToFile(f'Final PHP versions found: {finalPHPVersions}')
return finalPHPVersions if finalPHPVersions else ['PHP 7.4', 'PHP 8.0', 'PHP 8.1', 'PHP 8.2', 'PHP 8.3', 'PHP 8.4', 'PHP 8.5']
return finalPHPVersions if finalPHPVersions else ['PHP 7.4', 'PHP 8.0', 'PHP 8.1', 'PHP 8.2', 'PHP 8.3', 'PHP 8.4', 'PHP 8.5', 'PHP 8.6']
except BaseException as msg:
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
logging.writeToFile(f'Error while finding php versions on system: {str(msg)}')
return ['PHP 7.4', 'PHP 8.0', 'PHP 8.1', 'PHP 8.2', 'PHP 8.3', 'PHP 8.4', 'PHP 8.5']
return ['PHP 7.4', 'PHP 8.0', 'PHP 8.1', 'PHP 8.2', 'PHP 8.3', 'PHP 8.4', 'PHP 8.5', 'PHP 8.6']
@staticmethod
def findApachePHPVersions():
# distro = ProcessUtilities.decideDistro()
# if distro == ProcessUtilities.centos:
# return ['PHP 5.3', 'PHP 5.4', 'PHP 5.5', 'PHP 5.6', 'PHP 7.0', 'PHP 7.1', 'PHP 7.2', 'PHP 7.3', 'PHP 7.4', 'PHP 8.0', 'PHP 8.1']
# elif distro == ProcessUtilities.cent8:
# return ['PHP 7.1','PHP 7.2', 'PHP 7.3', 'PHP 7.4', 'PHP 8.0', 'PHP 8.1']
# elif distro == ProcessUtilities.ubuntu20:
# return ['PHP 7.2', 'PHP 7.3', 'PHP 7.4', 'PHP 8.0', 'PHP 8.1']
# else:
# return ['PHP 7.0', 'PHP 7.1', 'PHP 7.2', 'PHP 7.3', 'PHP 7.4', 'PHP 8.0', 'PHP 8.1', 'PHP 8.2', 'PHP 8.3', 'PHP 8.4', 'PHP 8.5']
"""
Dynamically detect available Apache PHP versions by scanning the system
"""
try:
# Run the shell command and capture the output
@@ -222,7 +215,7 @@ class PHPManager:
except BaseException as msg:
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
logging.writeToFile(f'Error while finding php versions on system: {str(msg)}')
return ['PHP 7.0', 'PHP 7.1', 'PHP 7.2', 'PHP 7.3', 'PHP 7.4', 'PHP 8.0', 'PHP 8.1', 'PHP 8.2', 'PHP 8.3', 'PHP 8.4', 'PHP 8.5']
return ['PHP 7.4', 'PHP 8.0', 'PHP 8.1', 'PHP 8.2', 'PHP 8.3', 'PHP 8.4', 'PHP 8.5', 'PHP 8.6']
@staticmethod
def getPHPString(phpVersion):
@@ -338,7 +331,7 @@ class PHPManager:
return 'PHP 8.3' # Default recommendation
# Priority order for recommendations
recommended_order = ['PHP 8.3', 'PHP 8.2', 'PHP 8.4', 'PHP 8.5', 'PHP 8.1', 'PHP 8.0', 'PHP 7.4']
recommended_order = ['PHP 8.3', 'PHP 8.2', 'PHP 8.4', 'PHP 8.5', 'PHP 8.6', 'PHP 8.1', 'PHP 8.0', 'PHP 7.4']
for recommended in recommended_order:
if recommended in all_versions:

View File

@@ -372,7 +372,10 @@ class phpUtilities:
centOSPHP = 'php85'
ubuntuPHP = 'php8.5'
phpPath = ApacheVhost.DecidePHPPath('86', virtualHostName)
if os.path.exists(phpPath):
centOSPHP = 'php86'
ubuntuPHP = 'php8.6'
######