2010-06-12 45 views
2

我試圖在本地機器上安裝一個小型沙箱,以便與Drupal一起玩耍。我創建了一些CCK類型;爲了創造幾個節點我寫了下面的腳本:PHP在Drupal中遷移數據時拋出「允許的內存耗盡」錯誤

chdir('C:\..\drupal'); 

require_once '.\includes\bootstrap.inc'; 
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); 
module_load_include('inc', 'node', 'node.pages'); 

$node = array('type' => 'my_type'); 

$link = mysql_connect(..); 
mysql_select_db('my_db'); 

$query_bldg = ' 
    SELECT stuff 
    FROM table 
    LIMIT 10 
'; 

$result = mysql_query($query_bldg); 

while ($row = mysql_fetch_object($result)) { 

$form_state = array(); 

$form_state['values']['name'] = 'admin'; 
$form_state['values']['status'] = 1; 
$form_state['values']['op'] = t('Save'); 

$form_state['values']['title'] = $row->val_a; 
$form_state['values']['my_field'][0]['value'] = $row->val_b; 
## About another dozen or so of similar assignments... 

drupal_execute('node_form', $form_state, (object)$node); 

} 

以下是php_errors.log一些相關線路:

[12-Jun-2010 05:02:47] PHP Notice: Undefined index: REMOTE_ADDR in C:\..\drupal\includes\bootstrap.inc on line 1299 
[12-Jun-2010 05:02:47] PHP Notice: Undefined index: REMOTE_ADDR in C:\..\drupal\includes\bootstrap.inc on line 1299 
[12-Jun-2010 05:02:47] PHP Warning: session_start(): Cannot send session cookie - headers already sent by (output started at C:\..\drupal\includes\bootstrap.inc:1299) in C:\..\drupal\includes\bootstrap.inc on line 1143 
[12-Jun-2010 05:02:47] PHP Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at C:\..\drupal\includes\bootstrap.inc:1299) in C:\..\drupal\includes\bootstrap.inc on line 1143 
[12-Jun-2010 05:02:47] PHP Warning: Cannot modify header information - headers already sent by (output started at C:\..\drupal\includes\bootstrap.inc:1299) in C:\..\drupal\includes\bootstrap.inc on line 709 
[12-Jun-2010 05:02:47] PHP Warning: Cannot modify header information - headers already sent by (output started at C:\..\drupal\includes\bootstrap.inc:1299) in C:\..\drupal\includes\bootstrap.inc on line 710 
[12-Jun-2010 05:02:47] PHP Warning: Cannot modify header information - headers already sent by (output started at C:\..\drupal\includes\bootstrap.inc:1299) in C:\..\drupal\includes\bootstrap.inc on line 711 
[12-Jun-2010 05:02:47] PHP Warning: Cannot modify header information - headers already sent by (output started at C:\..\drupal\includes\bootstrap.inc:1299) in C:\..\drupal\includes\bootstrap.inc on line 712 
[12-Jun-2010 05:02:47] PHP Notice: Undefined index: REMOTE_ADDR in C:\..\drupal\includes\bootstrap.inc on line 1299 
[12-Jun-2010 05:02:48] PHP Fatal error: Allowed memory size of 239075328 bytes exhau sted (tried to allocate 261904 bytes) in C:\..\drupal\includes\form.inc on line 488 
[12-Jun-2010 05:03:22] PHP Fatal error: Allowed memory size of 239075328 bytes exhausted (tried to allocate 261904 bytes) in C:\..\drupal\includes\form.inc on line 488 
[12-Jun-2010 05:04:34] PHP Fatal error: Allowed memory size of 262144 bytes exhausted (tried to allocate 261904 bytes) in Unknown on line 0 

此時任何動作的PHP發生在最後的錯誤結果如上所示。我試圖在最終的致命錯誤之前增加php.ini中memory_limit的值,這顯然沒有幫助。

如何消除錯誤?我是否正確地將數據遷移到Drupal,或者應該直接操作cck表?

的Windows XP
PHP 5.3.2 VC6
Apache 2.2的

+0

因爲你的致命錯誤是內存相關的嘗試分配更多的內存。 – Andreas 2010-06-12 21:30:30

+0

這是我嘗試的第一件事。我認爲超越512MB是一個可行的解決方案。 – Stan 2010-06-12 22:19:26

回答

0

究竟是 'node_form' 呼叫在做什麼?我猜這是$ form_state數據,並從它建立一些巨大的內存結構。這意味着:

a)你必須增加(或消除)內存的限制 - Drupal的建設事大,而且你不給它的空間來工作

B)更改node_form東西,所以它建立一次小塊。可能會間隔刷新輸出到客戶端?保存到磁盤?

相關問題