| @@ -21,15 +21,14 @@ | ||
| 21 | 21 | var serverMaxExecTime = metasyncExecSettingsData.serverMaxExecTime; |
| 22 | 22 | var serverMaxMemory = metasyncExecSettingsData.serverMaxMemory; |
| 23 | 23 | var canChangeMemory = metasyncExecSettingsData.canChangeMemory; |
| 24 | 24 | |
| 25 | - // Normalize string 'Infinity' to JS Infinity | |
| 26 | - if (serverMaxExecTime === 'Infinity') { | |
| 27 | - serverMaxExecTime = Infinity; | |
| 28 | - } | |
| 29 | - if (serverMaxMemory === 'Infinity') { | |
| 30 | - serverMaxMemory = Infinity; | |
| 31 | - } | |
| 25 | + // Normalize to numbers ('Infinity' marker -> JS Infinity). wp_localize_script | |
| 26 | + // casts every scalar to a string, so these arrive as e.g. "2048"; comparing a | |
| 27 | + // string field value against a string limit ("256" > "2048") would be | |
| 28 | + // lexicographic and wrong, so coerce to numbers here. | |
| 29 | + serverMaxExecTime = (serverMaxExecTime === 'Infinity') ? Infinity : parseInt(serverMaxExecTime, 10); | |
| 30 | + serverMaxMemory = (serverMaxMemory === 'Infinity') ? Infinity : parseInt(serverMaxMemory, 10); | |
| 32 | 31 | |
| 33 | 32 | // Real-time validation for server limits |
| 34 | 33 | function checkServerLimits() { |
| 35 | 34 | var maxExecTime = parseInt($('#max_execution_time').val()) || 0; |
| @@ -83,9 +82,9 @@ | ||
| 83 | 82 | if (!canChangeMemory) { |
| 84 | 83 | return; |
| 85 | 84 | } |
| 86 | 85 | var value = parseInt($(this).val()) || 0; |
| 87 | - var isValid = value >= 64 && value <= 512 && (serverMaxMemory === Infinity || value <= serverMaxMemory); | |
| 86 | + var isValid = value >= 64 && (serverMaxMemory === Infinity || value <= serverMaxMemory); | |
| 88 | 87 | highlightInvalidField($(this), isValid); |
| 89 | 88 | }); |
| 90 | 89 | |
| 91 | 90 | // Initial check on page load |
| @@ -129,10 +128,10 @@ | ||
| 129 | 128 | } |
| 130 | 129 | |
| 131 | 130 | // Only validate memory limit if server allows changing it |
| 132 | 131 | if (canChangeMemory) { |
| 133 | - if (formData.max_memory_limit < 64 || formData.max_memory_limit > 512) { | |
| 134 | - showMessage('Max Memory Limit must be between 64 and 512 MB.', 'error'); | |
| 132 | + if (formData.max_memory_limit < 64) { | |
| 133 | + showMessage('Max Memory Limit must be at least 64 MB.', 'error'); | |
| 135 | 134 | highlightInvalidField($('#max_memory_limit'), false); |
| 136 | 135 | if (!hasError) { |
| 137 | 136 | errorField = $('#max_memory_limit'); |
| 138 | 137 | hasError = true; |
| @@ -137,9 +136,9 @@ | ||
| 137 | 136 | errorField = $('#max_memory_limit'); |
| 138 | 137 | hasError = true; |
| 139 | 138 | } |
| 140 | 139 | } else if (serverMaxMemory !== Infinity && formData.max_memory_limit > serverMaxMemory) { |
| 141 | - showMessage('Max Memory Limit exceeds server limit of ' + serverMaxMemory + ' MB. Please reduce the value.', 'error'); | |
| 140 | + showMessage('Max Memory Limit must be between 64 and ' + serverMaxMemory + ' MB.', 'error'); | |
| 142 | 141 | highlightInvalidField($('#max_memory_limit'), false); |
| 143 | 142 | if (!hasError) { |
| 144 | 143 | errorField = $('#max_memory_limit'); |
| 145 | 144 | hasError = true; |