Files
Investidor-V2/tools/portal-stability-opcache.py
nala 287e991486
tests / ci (push) Waiting to run
oportunidades 7
2026-10-13 11:40:29 +02:00

26 lines
1.8 KiB
Python

"""Provide an isolated Windows OPcache identity/fallback; do not edit destination php.ini."""
from pathlib import Path
import json, hashlib
ROOT=Path(__file__).resolve().parent.parent
PRIVATE=ROOT/'storage/app/private/investmoz-v2/portal-audit'
read=lambda p:json.loads(Path(p).read_text(encoding='utf-8-sig'))
plan=read(PRIVATE/'portal-stability-latest.json');source=Path(plan['source'])
ini_dir=source/'apache-qa/php-ini';ini_dir.mkdir(exist_ok=False)
cache=source/'apache-qa/opcache';cache.mkdir(exist_ok=False)
original=Path(plan['php_ini'])
text=original.read_text(encoding='utf-8-sig')
text+='\n; Isolated Windows QA: own SHM identity and writable file-cache fallback.\n'
text+='opcache.cache_id=investmoz_stability_20261011\nopcache.file_cache="'+cache.as_posix()+'"\nopcache.file_cache_fallback=1\nopcache.file_cache_consistency_checks=1\n'
(ini_dir/'php.ini').write_text(text,encoding='utf-8')
conf=Path(plan['compatible_apache_conf']);text=conf.read_text(encoding='utf-8')
text=text.replace('PHPIniDir "C:/laragon/bin/php/php-8.5.11-Win32-vs17-x64"','PHPIniDir "'+ini_dir.as_posix()+'"')
conf.write_text(text,encoding='utf-8')
plan['runtime_correction']['opcache']={'active_ini_sha256':hashlib.sha256(original.read_bytes()).hexdigest(),
'qa_ini_sha256':hashlib.sha256((ini_dir/'php.ini').read_bytes()).hexdigest(),
'own_cache_id':True,'file_cache_fallback':True,'active_ini_modified':False,
'official_source':'https://www.php.net/manual/en/opcache.configuration.php'}
plan['runtime_correction']['php_modules_and_ini_identical']=False
plan['runtime_correction']['php_modules_identical']=True
(PRIVATE/'portal-stability-latest.json').write_text(json.dumps(plan,ensure_ascii=False,indent=2),encoding='utf-8')
print(json.dumps({'result':'QA_OPcache_configuration_prepared','active_ini_modified':False,'opcache_disabled':False}))