Skip to content

Commit 4453c3f

Browse files
CopilotPDowney
andcommitted
fix: exit with error when memory cannot be determined instead of 1024 MB fallback
Agent-Logs-Url: https://github.com/EngineScript/EngineScript/sessions/cdd9b3a8-a9d8-4d72-9e36-f65ab2d7f3bf Co-authored-by: PDowney <[email protected]>
1 parent b96360a commit 4453c3f

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ All notable changes to EngineScript will be documented in this file.
44

55
Changes are organized by date, with the most recent changes listed first.
66

7+
## 2026-04-01
8+
9+
### 🐛 PHP CONFIG UPDATE SCRIPT HARDENING
10+
11+
- **Added `AVAILABLE_MEMORY` validation** in `scripts/update/php-config-update.sh`. If `/proc/meminfo` is unavailable or `awk` returns an empty/non-numeric value, the script now falls back to `MemTotal`, and if that also fails, exits with an error rather than proceeding with an unknown memory value.
12+
- **Added error checking for `cp -f` operations** in `scripts/update/php-config-update.sh`. The three config file copy operations (`php.ini`, `php-fpm.conf`, `www.conf`) now use `if ! cp -f ...` to detect failures and exit with an error message rather than silently continuing with a broken or missing configuration.
13+
714
## 2026-03-27
815

916
### 🐛 DEBUG MODE ADDED TO ALL INSTALL AND UPDATE SCRIPTS

scripts/update/php-config-update.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ calculate_php() {
2323
# No fallbacks needed as this script will be run on a system with a modern kernel.
2424
# MemAvailable field will be present in /proc/meminfo on modern kernels and is the most accurate representation of available memory for applications.
2525
AVAILABLE_MEMORY=$(awk '/MemAvailable/ {printf "%d", $2/1024}' /proc/meminfo)
26-
# Validate that AVAILABLE_MEMORY is a non-empty numeric value; fall back conservatively if not.
26+
# Validate that AVAILABLE_MEMORY is a non-empty numeric value; exit if it cannot be determined.
2727
if ! [[ "${AVAILABLE_MEMORY}" =~ ^[0-9]+$ ]]; then
28-
# Fallback: use MemTotal if available, otherwise default to 1024 MB.
28+
# Fallback: use MemTotal if available, otherwise exit with an error.
2929
AVAILABLE_MEMORY=$(awk '/MemTotal/ {printf "%d", $2/1024}' /proc/meminfo 2>/dev/null || echo "")
3030
if ! [[ "${AVAILABLE_MEMORY}" =~ ^[0-9]+$ ]]; then
31-
echo "Warning: Unable to determine available memory from /proc/meminfo; using conservative default of 1024 MB." >&2
32-
AVAILABLE_MEMORY=1024
31+
echo "Error: Unable to determine available memory from /proc/meminfo; cannot continue." >&2
32+
exit 1
3333
fi
3434
fi
3535
AVERAGE_PHP_MEMORY_REQ_MB=80 # average PHP memory requirement in MB

0 commit comments

Comments
 (0)