EE 2.0 Build 20100810
Entries appear to get cached when using $this->EE->api_channel_entries->submit_new_entry.
In config/database.php the cache is set to FALSE
$db[‘expressionengine’][‘cache_on’] = FALSE;
In Admin/System Administration/ Database Settings, the Enable SQL Query Caching is set to No
Enable SQL Query Caching: no
Apparently ExpressionEngine 2.1.0 build 20100805 disabled db caching but I am still seeing an issue:
* Temporarily disabled db caching for all installations until all db caching issues are resolved.
HOW TO REPRODUCE:
Create a channel called “test”
Do not assign any custom fields or categories.
We’ll just use the title.
Assign the default status group to the channel (open/closed)
Note the channel id for the new channel (test). You’ll need it in the code below:
Create a template group called Test
Add two templates (index and add) - see below. Be sure to Allow PHP / output for the add template.
Go to site_url.com/test
THen click add.
Add a title and submit. You will see that the list (index template) will only occupationally update. You’ll need to refresh the page (site_url.com/test) to see the new entry. Keep adding titles - some will display immediately while others will need a page refresh.
template: index
<a href="http://{site_url}test/add">+ Add</a>
{exp:channel:entries channel="test" orderby="date" sort="desc"}
{if no_results}No test data found.{/if}
<div>{total_results}{title}</div>
{/exp:channel:entries}
NOTE: in the template add, you will need to modify the following two lines with your channel id for for test - in my case, my channel id is11.
'channel_id' => 11, // temporary hack for ee bug
if ($this->EE->api_channel_entries->submit_new_entry(11, $data) === FALSE)template: add
<?php
$this->EE->load->library('api');
$this->EE->load->library('form_validation');
$this->EE->load->helper('form');
$error_string = '';
$this->EE->form_validation->set_rules('title', 'title', 'trim|required|xss_clean');
if ($this->EE->form_validation->run() == FALSE)
$error_string = '<div class="error">'.$this->EE->form_validation->error_string().'</div>';
else if (isset($_POST['submit-add']))
{
$data = array( 'title' => $this->EE->input->post('title'),
'entry_date' => time(),
'expiration_date' => time()+30*24*60*60, // expires in 30 days
'author_id' => $this->EE->session->userdata['member_id'],
'status' => 'open',
'channel_id' => 11, // temporary hack for ee bug
);
$this->EE->api->instantiate('channel_entries');
$this->EE->api->instantiate('channel_fields');
if ($this->EE->api_channel_entries->submit_new_entry(11, $data) === FALSE)
{
show_error('An Error Occurred Creating the Entry');
}
$this->EE->functions->redirect('/test');
return;
}
// display add form
echo $error_string;
echo form_open('test/add');
$data = array(
'name' => 'title',
'id' => 'title',
'value' => set_value('title', ''),
'maxlength' => '40',
'size' => '40',
);
echo 'Title '.form_input($data);
echo '
';echo '
';
echo form_submit('submit-add', 'Submit Test');
echo form_close();
?>