Empty table list when two or more databases used

beholder - September 11, 2008 - 09:17
Project:DB Maintenance
Version:6.x-2.0-beta1
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:needs work
Description

I have two databases in my config, so $db_url is something like this:

$db_url = array(
  'default' => 'mysql://...',
  'forum' => 'mysql://...'
);

Dut your module shows empty lists of tables on settings page. I have found that _db_maintenance_determine_software() function didn't respect that $db_url can be an array. It's assumed that this variable is string. You need some more testing before doing strpos().

#1

szy - December 21, 2008 - 12:11

Confirmed. There are two databases (the second one is from vBulletin), so lists
for choosing tables in DB Maintenance options are empty (attachment).

Szy.

AttachmentSize
dbmaintenance_081221.gif 9.55 KB

#2

szy - December 21, 2008 - 12:14
Version:6.x-1.1» 6.x-2.0-beta1
Priority:normal» critical

#3

Charles Oertel - January 13, 2009 - 15:51

I am looking at this module on a site that uses two postgres databases and ran into the same problem. Attached is a patch of the code I used to fix it. This is my first ever contribution to a module, so forgive and give me feedback if there is a problem.

AttachmentSize
db_maintenance-6.x-2.0-beta1.patch 2.4 KB

#4

szy - January 13, 2009 - 20:44
Status:active» needs review

@Charles Oertel, works fine for me, thank you.

Szy.

#5

deekayen - January 14, 2009 - 01:06
Status:needs review» needs work

Please run the code through coder.

I haven't tried the patch yet, but can you just type cast (array) or does this solution really require is_array()?

#6

Charles Oertel - January 14, 2009 - 07:59

Thanks for pointing me to coder - though it seems that my patch has little to do with the errors it generates. Perhaps you should log this as a separate issue.

I coded the patch to be easy to understand and maintain, and prefer to keep my variables as fixed types. If you prefer a different style or technique, please enlighten me. Is there a problem with using is_array?

#7

Charles Oertel - January 14, 2009 - 12:22

Further analysis reveals a number of places in the code where the assumption is made that there in only one database. I am working on fixing these, as well as allowing the multiple databases to be of any type (e.g. one mysql and one postgres say).

The settings also need to provide an option for the pg_dump path, which I will add.

#8

Charles Oertel - January 16, 2009 - 14:17

Attached is my work to date - quite a lot of changes. I ended up using the backup_migrate module to do most of what I wanted, and it depends on some of the functions in this module to detect databases and parse dump parameters.

So, for a fuller solution, look at using the patched version of backup_migrate with the patched version of this module.

AttachmentSize
db_maintenance-6.x-2.0-beta1.patch 10.28 KB

#9

Charles Oertel - January 20, 2009 - 11:49

Fixes to the patch to create a .pgpass file populated with the database logon credentials. This is needed because pg_dump does not allow passwords to be passed via the parameter line. The .pgpass file is created in the parent of the drupal instance. If this is not the home directory of the apache user, you need to tell pg_dump the path to this file as follows:

`PGPASSWORDFILE=../.pgpass; pgdump ...`

AttachmentSize
db_maintenance-6.x-2.0-beta1.patch 10.8 KB

#10

kakarot - November 3, 2009 - 15:37

That patch is for db_maintenance-6.x-2.0 which isn't available in the project download section... dou you have a db_maintenance-6.x-1.1 patch version?
I've tried to adapt the patch to 1.1 module version, but when i try to save database, the backup is empty :( obviously this shouldn't be so easy.
Any ideas?

 
 

Drupal is a registered trademark of Dries Buytaert.