問題描述
根據 WordPress 的代碼,FS_METHOD = 'direct'是適當的選擇。
(Primary Preference) “direct” forces it to use Direct File I/O requests from within PHP, this is fraught with opening up security issues on poorly configured hosts, This is chosen automatically when appropriate.
http://codex.wordpress.org/Editing_wp-config.php#WordPress_Upgrade_Constants
適合的標準是什麼?
最佳解決方案
這裏是代碼 from wp-admin/includes/file.php:
if ( ! $method && function_exists('getmyuid') && function_exists('fileowner') ){
if ( !$context )
$context = WP_CONTENT_DIR;
// If the directory doesn't exist (wp-content/languages) then use the parent directory
// as we'll create it.
if ( WP_LANG_DIR == $context && ! is_dir( $context ) )
$context = dirname( $context );
$context = trailingslashit($context);
$temp_file_name = $context . 'temp-write-test-' . time();
$temp_handle = @fopen($temp_file_name, 'w');
if ( $temp_handle ) {
if ( getmyuid() == @fileowner($temp_file_name) )
$method = 'direct';
@fclose($temp_handle);
@unlink($temp_file_name);
}
}
測試似乎是
-
我們可以在 wp-content 或 wp-content /languages 目錄中創建一個臨時文件嗎?
-
該文件是否屬於當前的 Unix 用户,即 wp-content 上沒有 setuid?
如果我們自己沒有指定 FS_METHOD,並且如果必要的文件系統調用檢查#2,則只執行此檢查。臨時文件隨後被清理。
參考文獻
注:本文內容整合自 Google/Baidu/Bing 輔助翻譯的英文資料結果。如果您對結果不滿意,可以加入我們改善翻譯效果:薇曉朵技術論壇。