View Full Version : Admin Data Entries Bug

Shawn Hall
August 1, 2012, 12:02 AM
This one is kind of major...

I added a data entry in the admin area and later decided I did not need it, so I deleted it. When I did this for some reason it removed ALL data entries in the Admin area!

I was able to go back into the database through phpMyAdmin and found that it had only deleted all the parent entries (Countries, US States, etc.) and all the other keys were still there. I fixed this by adding the data entries back in the admin area, then correcting the ID in the database through phpMyAdmin to what it was originally and everything came back.

If this happens to anybody don't panic (like I did initially!), it's not too difficult to fix, but there is a bug somewhere in the Admin area that must have caused this.

Peter Jonsson
August 1, 2012, 02:27 AM
Same here some days ago.

August 1, 2012, 03:48 AM

you can fix the problem in the following way:

- Open the file: includes/classes/admin/rlFormats.class.php
- go to method ajaxDeleteItem() and find this code:

$data = explode(',', $data);
$key = $data[0];
$format = $data[1];

and change it to:

$data = explode(',', $data);
$key = $data[0];
$format = $data[1];

if ( !$key )
return $_response;

- then go to ajaxDeleteFormat() method and update it with:

function ajaxDeleteFormat( $key = false )
global $_response, $lang, $config, $id;

if ( !$key )

$this -> setTable('data_formats');

// check admin session expire
if ( $this -> checkSessionExpire() === false )
$redirect_url = RL_URL_HOME . ADMIN ."/index.php";
$redirect_url .= empty($_SERVER['QUERY_STRING']) ? '?session_expired' : '?'. $_SERVER['QUERY_STRING'] .'&session_expired';
$_response -> redirect( $redirect_url );

$lang_keys[] = array(
'Key' => 'data_formats+name+' . $key,

// get format ID
$id = $this -> getOne('ID', "`Key` = '{$key}'", 'data_formats');

$GLOBALS['rlHook'] -> load('apPhpFormatsAjaxDeleteFormatPreDelete');

$this -> rlActions -> delete( array( 'Key' => $key ), array('data_formats', 'lang_keys'), null, 1, $key, $lang_keys );
$del_mode = $this -> rlActions -> action;

if ( !$config['trash'] )
// get child keys
$child_keys = $this -> fetch(array('Key'), array('Parent_ID' => $id));

// remove items lang keys
foreach ($child_keys as $cKey => $cVal)
$this -> query("DELETE FROM `".RL_DBPREFIX."lang_keys` WHERE `Key` = 'data_formats+name+".$child_keys[$cKey]['Key']."'");

// remove child items
$this -> query("DELETE FROM `".RL_DBPREFIX."data_formats` WHERE `Parent_ID` = '{$id}'");

$GLOBALS['rlHook'] -> load('apPhpFormatsAjaxDeleteFormat');

$GLOBALS['rlCache'] -> updateDataFormats();

$_response -> script("dataFormatGrid.reload();");
$_response -> script("printMessage('notice', '{$lang['item_' . $del_mode]}')");

return $_response;

August 1, 2012, 01:40 PM
You mean it remove all your entries?

Has anyone applied this fix?

August 8, 2012, 06:11 AM
It removes all parent entries in database.. But for you as admin seems that deleted all entries, because you cant manage child items without parents :)

It has been fixed in 4.1 version. Changes Vladimir posted will fix the problem, or just wait update and apply patch.

Abelardo Leal
May 23, 2013, 10:04 PM

I have imported data entries with DataEntriesImport plugin from a txt file with one blank line, then when I go to Data Entries and delete the blank record, it completly deleted the data_formats table and delete all data entries from table lang_keys.

I have tested and it only happen when try to delete one blank entry...

Flynax General 4.1