CMS MADE SIMPLE FORGE

CMS Made Simple Core

 

[#8960] not possible to rename prefix in database - pages not shown in admin

avatar
Created By: Lone Jacobsen (lone)
Date Submitted: Wed Feb 20 09:49:40 -0500 2013

Assigned To:
Version: 1,11,4
CMSMS Version: None
Severity: Minor
Resolution: Won't Fix
State: Closed
Summary:
not possible to rename prefix in database - pages not shown in admin
Detailed Description:
I have a new install of version 1.11.4.
This site I have copied to anothe webhost, and I have renamed the prefix
directly in the database with:
rename table xxx_additional_users to yyy_additional_users;
And changed the prefix in config, uploaded config and cleared cache.
This rename I have done succesfully in previous versions of cmsms, everything
worked fine.

But I cannot get this to work with 1.11.4.

When in the english version:
In version 1.11.4 pages are no longer listed i admin, though they exist in the
database.
I can create new pages, they exist in database, but they are not shown in admin.
The 'Parent' dropdown is missing on the page.

When I choose Danish as language in user settings:
I cannot create a page: a warning that the 'Parent' option is missing prevents
it.
The 'Parent' dropdown is missing on the page.

After renaming the tables back to the former name in the database and in config,
and clearing the cache, everything works fine again.


History

Comments
avatar
Date: 2013-02-21 11:07
Posted By: Robert Campbell (calguy1000)

we cannot and will not go through this fishing expedition.
You will need to provide more errors and exactly where the problem is occurring
for us to be able to look into this issue.
      
avatar
Date: 2013-02-21 11:54
Posted By: Lone Jacobsen (lone)

I will try to be more explicit:

I have done this: 
changed prefix in database + config and cleared cache.

I expected the result: 
That CMSMS 1.11.4 would work as usual.
This has been true in previous versions e.g. 1.10.3

I got the result:
That CMSMS 1.11.4 worked as usual EXEPT there was problems with 
showing and creating pages in admin under Content->Pages.

---------------------------------------------------------------------

I then changed prefix back to former prefix in database + config and cleared
cache.
CMSMS 1.11.4 then worked as usual, including showing and creating pages.

---------------------------------------------------------------------

The problems I encountered with showing and creating pages in admin 
under Content->Pages were the following:

When in the english language version:
1. In admin, under Content->Pages, pages are no longer listed i admin.
The area is empty = no pages (0) are listed allthough I can see that they do
exist in the database.

2. Clicking Add New Content creates a new page, it is created in the database, 
but is not shown in admin under Content->Pages

3. The 'Parent' dropdown is missing on the page that is created.

When I choose Danish as language in user settings:
1. Clicking Add New Content, I cannot create a page: 
a warning that the 'Parent' option is missing prevents it.
      
avatar
Date: 2013-02-22 08:01
Posted By: Lone Jacobsen (lone)

System info

Cms Version: [b]1.11.4[/b]

Installed Modules:

    CMSMailer: [b]5.2.1[/b]
    CMSPrinting: [b]1.0.3[/b]
    FileManager: [b]1.4.3[/b]
    MenuManager: [b]1.8.4[/b]
    OwnersManual: [b]1.0.3[/b]
    ModuleManager: [b]1.5.5[/b]
    News: [b]2.12.10[/b]
    Search: [b]1.7.7[/b]
    ThemeManager: [b]1.1.7[/b]
    CGExtensions: [b]1.31.3[/b]
    CGSimpleSmarty: [b]1.5.2[/b]
    CGSmartImage: [b]1.9.5[/b]
    TinyMCE: [b]2.9.11[/b]
    Gallery: [b]1.6[/b]
    CodeMirror: [b]3.0.0[/b]


Config Information:

    php_memory_limit: [b][/b]
    process_whole_template: [b][/b]
    output_compression: [b][/b]
    max_upload_size: [b]200000000[/b]
    url_rewriting: [b]mod_rewrite[/b]
    page_extension: [b][/b]
    query_var: [b]page[/b]
    image_manipulation_prog: [b]GD[/b]
    auto_alias_content: [b]true[/b]
    locale: [b][/b]
    default_encoding: [b]utf-8[/b]
    admin_encoding: [b]utf-8[/b]
    set_names: [b]true[/b]


Php Information:

    phpversion: [b]5.3.3[/b]
    md5_function: [b]On[/b] (True)
    gd_version: [b]2[/b]
    tempnam_function: [b]On[/b] (True)
    magic_quotes_runtime: [b]Off[/b] (False)
    E_STRICT: [b]0[/b]
    E_DEPRECATED: [b]0[/b]
    memory_limit: [b]512M[/b]
    max_execution_time: [b]60[/b]
    output_buffering: [b]4096[/b]
    safe_mode: [b]Off[/b] (False)
    file_uploads: [b]On[/b] (True)
    post_max_size: [b]200M[/b]
    upload_max_filesize: [b]200M[/b]
    session_save_path: [b]No check because open basedir active[/b]
    session_use_cookies: [b]On[/b] (True)
    xml_function: [b]On[/b] (True)
    xmlreader_class: [b]On[/b] (True)


Server Information:

    Server Api: [b]apache2handler[/b]
    Server Db Type: [b]MySQL (mysqli)[/b]
    Server Db Version: [b]5.1.67[/b]
Server Db Grants: [b]Found a "GRANT ALL" statement that appears to be
suitable[/b]


      
avatar
Date: 2014-03-10 09:47
Posted By: Georg Busch (nan)

The problem is about indexes.
CMSms uses index names that contains the db prefix.
If you change the db prefix CMSms queries the database using indexes with the
new db prefix.
But these new indexes does not exist in the database.
(you should see that if you turn on debug mode)

You need to recreate/rename those indexes that starts with the old db prefix.

1st make a backup of your database!

2nd create a userdefined tag and paste the following code (adapt the db prefix
to your old prefix):

===

$old_db_prefix = "cms_"; // change this to match your own OLD db prefix

$db       =& cmsms()->GetDb();
$dbdict   = NewDataDictionary($db);
$dbresult = $db->Execute("SHOW TABLES");
$tables   = array();

while($dbresult && $row = $dbresult->FetchRow())
	$tables = array_merge($tables, array_values($row));

foreach($tables as $t)
{
$dbresult = $db->Execute("SHOW INDEX FROM `$t` WHERE `Key_name` LIKE '" .
$old_db_prefix . "%'");

	$indizes  = array();

	if(version_compare($db->Version(), "5.7", ">="))
	{
		while($dbresult && $row = $dbresult->FetchRow())
$db->Execute("ALTER TABLE `$t` RENAME INDEX `" . $row['Key_name'] . "` TO '"
. cms_db_prefix() . substr($row['Key_name'], strlen($old_db_prefix)) . "'";
		continue;
	}

	while($dbresult && $row = $dbresult->FetchRow())
		$indizes[$row['Key_name']][] = $row['Column_name'];

	foreach($indizes as $k => $v)
	{
		$new_index = cms_db_prefix() . substr($k, strlen($old_db_prefix));
		$db->Execute("ALTER TABLE `$t` DROP INDEX `" . $k . "`");
$db->Execute("ALTER TABLE `$t` ADD INDEX `" . $new_index . "` (`" .
implode("`,`", $v) . "`)");
	}
}

===


3rd process this udt in backend.

4th maybe you need to clear the cache after this.
      
avatar
Date: 2014-03-11 00:58
Posted By: Robert Campbell (calguy1000)

This is not a bug with CMSMS but with how the user migrated tables and
databases.
would have been simpler and easier to export the database to a .sql file and
edit it.
      
Updates

Updated: 2014-03-11 00:58
resolution_id: 10 => 8
cmsms_version_id: 29887 => -1
state: Open => Closed

Updated: 2013-02-21 11:07
resolution_id: => 10