WordPress’ memory limit can be independently set to anything however will not go over PHP’s own limit. This will retrieve PHP’s memory limit. Will attempt to retrieve from default location for Kinsta sites then fallback to what PHP’s loaded ini file. Please note that sometimes there is a difference between CLI’s memory limits and web request limits.
php_version=$( php -v | head -n1 | cut -d ' ' -f 2 | cut -d '.' -f 1,2 )
php_file=$( ls /etc/php/8.3/fpm/pool.d/*.conf | head -n 1 )
if [ -f "$php_file" ]; then
php_memory=$( cat "$php_file" | grep "memory_limit" )
fi
if [[ "$php_memory" == "" ]]; then
php_ini=$( wp eval 'echo php_ini_loaded_file();' --skip-plugins --skip-themes )
php_memory=$( cat "$php_ini" | grep "memory_limit" )
fi
read -r -d '' php_code << heredoc
\$line = '$php_memory';
\$parts = explode('=', \$line, 2);
if (isset(\$parts[1])) {
echo trim(\$parts[1]);
}
heredoc
php -r "$php_code"