Table query error

dennys - October 17, 2007 - 00:03
Project:Database Administration
Version:5.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

When I upgraded to 2007-10-16 version, I got the message in table query. This function is ok in previous version. My Drupal is 5.2

warning: array_merge() [function.array-merge]: Argument #1 is not an array in /www/includes/menu.inc on line 415.
warning: Missing argument 1 for drupal_get_form() in /www/includes/form.inc on line 48.
warning: Missing argument 1 for drupal_retrieve_form() in /www/includes/form.inc on line 178.
warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, '' was given in /www/includes/form.inc on line 217.

#1

bago - October 18, 2007 - 17:31

At line 85 I added the $table = $tables[0] to make it work again:

  elseif (strstr(drupal_get_path_alias($_GET['q']), 'admin/build/database')) {
    $tables = dba_get_active_tables(0);
    if (!empty($tables) && count($tables) == 1) {
      // You can only view or describe one table at a time.
      $table = $tables[0];        <----------- ADD THIS

      // Regular subtabs.

#2

dennys - October 18, 2007 - 23:30
Status:active» needs review

Thanks, it works again now.

#3

jiangxijay - October 22, 2007 - 19:23

I had this exact problem, and the solution worked.

#4

dww - October 23, 2007 - 07:50
Status:needs review» needs work

Thanks for the report and the proposed fix. However, that's not really a patch. Please see http://drupal.org/patch and attach an actual patch. Makes it much easier to review and apply the changes to the code. Thanks!

#5

jiangxijay - October 23, 2007 - 13:47

Making an official patch is beyond my very limited skills ;)

I hope bago or someone else will do so ...

#6

dennys - October 23, 2007 - 13:59
Status:needs work» needs review

Here is the patch for bago's code. Please help to review it, thanks. I use this command to generate the patch
diff -up dba.module.old dba.module > dba.diff

AttachmentSize
dba_0.diff 399 bytes

#7

dww - October 23, 2007 - 15:53

Thank for the patch. Upon closer inspection:

A) Your patch had a bunch of whitespace after the ; in the line you added.

B) I think $table = reset($tables) is generally safer, since that will always return the first element in the array, even if the numeric indexes don't start from 0 for some reason.

C) A little CVS archeology shows that this was broken by my patch for HEAD over at http://drupal.org/node/154227#comment-264226 (comment #2). I simply left out this important line of code (which is already in the version in DRUPAL-4-7) from the patch I had rolled for HEAD. Whoops. ;)

Anyway, I committed the fix using reset() to HEAD (so that DRUPAL-4-7 and HEAD are in sync again regarding this code) and all those menu items are now working in my 5.x test site.

Sorry about the bug, and thanks for the report and first try at a fix! I didn't list y'all in the CVS commit since I didn't use your code, but I totally appreciate you taking the time to find the problem and supply a patch. Hopefully the next time I'll just be able to use your patch directly and be able to put "#XXXXX by bago and dannys: Fixed ..." in the CVS log. ;)

Cheers,
-Derek

#8

dww - October 23, 2007 - 15:54
Status:needs review» fixed

#9

Anonymous - November 12, 2007 - 22:42
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.