インストール プロファイルを作成していて、"max_execution_time" と "memory_limit" の値が低い場合にユーザーに通知したいと考えています。私が理解しているように、Drupal は考えられる要件について myprofile.install ファイルをチェックする必要があるため、そこに以下を配置しました。
function myprofile_requirements($phase) {
$requirements = array();
// Min required PHP execution time
$min_time = 60;
// Min required memory limit, Mb
$min_memory = 128;
// Get current value of "max_execution_time"
$time = ini_get('max_execution_time');
// Get current value of "max_execution_time"
$memory = ini_get('memory_limit');
// Get "raw" numeric value
preg_match("|\d+|", $memory, $value);
$severity_time = ($time < $min_time) ? REQUIREMENT_WARNING : REQUIREMENT_OK;
$severity_memory = ($value[0] < $min_memory) ? REQUIREMENT_WARNING : REQUIREMENT_OK;
$t = get_t();
if ($phase == 'install') {
$requirements['max_execution_time'] = array(
'title' => $t('PHP max execution time'),
'value' => $t('Please increase the parameter "max_execution_time" in your PHP settings . Recommended value is at least @min sec. and more (now you have @current sec.',
array('@min' => $min_time, '@current' => $time)),
'severity' => $severity_time,
);
$requirements['memory_limit'] = array(
'title' => $t('PHP memory limit'),
'value' => $t('Please increase the parameter "memory_limit" in your PHP settings . Recommended value is at least @minM and more (now you have @current',
array('@min' => $min_memory, '@current' => $memory)),
'severity' => $severity_memory,
);
}
return $requirements;
}
動作しません - Drupal シンプルは上記のコードを無視します。どうしたの?