Skip to content

Commit 614bf7c

Browse files
authored
Merge pull request #1584 from master3395/v2.5.5-dev
- 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.
2 parents 4bedb9c + cef0192 commit 614bf7c

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

managePHP/phpManager.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def findPHPVersions():
5858
# Method 2: Check system-wide PHP installations
5959
try:
6060
# Check for system PHP versions
61-
system_php_versions = ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']
61+
system_php_versions = ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5', '8.6']
6262
for version in system_php_versions:
6363
formatted_version = f'PHP {version}'
6464
if formatted_version not in finalPHPVersions:
@@ -117,7 +117,7 @@ def findPHPVersions():
117117

118118
# Method 4: Fallback to checking common PHP versions
119119
if not finalPHPVersions:
120-
fallback_versions = ['PHP 7.4', 'PHP 8.0', 'PHP 8.1', 'PHP 8.2', 'PHP 8.3', 'PHP 8.4', 'PHP 8.5']
120+
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']
121121
for version in fallback_versions:
122122
try:
123123
phpString = PHPManager.getPHPString(version)
@@ -145,25 +145,18 @@ def version_sort_key(version):
145145
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
146146
logging.writeToFile(f'Final PHP versions found: {finalPHPVersions}')
147147

148-
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']
148+
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']
149149

150150
except BaseException as msg:
151151
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
152152
logging.writeToFile(f'Error while finding php versions on system: {str(msg)}')
153-
return ['PHP 7.4', 'PHP 8.0', 'PHP 8.1', 'PHP 8.2', 'PHP 8.3', 'PHP 8.4', 'PHP 8.5']
153+
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']
154154

155155
@staticmethod
156156
def findApachePHPVersions():
157-
# distro = ProcessUtilities.decideDistro()
158-
# if distro == ProcessUtilities.centos:
159-
# 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']
160-
# elif distro == ProcessUtilities.cent8:
161-
# return ['PHP 7.1','PHP 7.2', 'PHP 7.3', 'PHP 7.4', 'PHP 8.0', 'PHP 8.1']
162-
# elif distro == ProcessUtilities.ubuntu20:
163-
# return ['PHP 7.2', 'PHP 7.3', 'PHP 7.4', 'PHP 8.0', 'PHP 8.1']
164-
# else:
165-
# 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']
166-
157+
"""
158+
Dynamically detect available Apache PHP versions by scanning the system
159+
"""
167160
try:
168161

169162
# Run the shell command and capture the output
@@ -222,7 +215,7 @@ def findApachePHPVersions():
222215
except BaseException as msg:
223216
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
224217
logging.writeToFile(f'Error while finding php versions on system: {str(msg)}')
225-
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']
218+
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']
226219

227220
@staticmethod
228221
def getPHPString(phpVersion):
@@ -338,7 +331,7 @@ def getRecommendedPHPVersion():
338331
return 'PHP 8.3' # Default recommendation
339332

340333
# Priority order for recommendations
341-
recommended_order = ['PHP 8.3', 'PHP 8.2', 'PHP 8.4', 'PHP 8.5', 'PHP 8.1', 'PHP 8.0', 'PHP 7.4']
334+
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']
342335

343336
for recommended in recommended_order:
344337
if recommended in all_versions:

plogical/phpUtilities.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,10 @@ def GetPHPVersionFromFile(vhFile, domainName=None):
372372
centOSPHP = 'php85'
373373
ubuntuPHP = 'php8.5'
374374

375-
375+
phpPath = ApacheVhost.DecidePHPPath('86', virtualHostName)
376+
if os.path.exists(phpPath):
377+
centOSPHP = 'php86'
378+
ubuntuPHP = 'php8.6'
376379

377380
######
378381

0 commit comments

Comments
 (0)