I'm trying to locate a problem I believe exists in system_update_6021(). During an upgrade from 5.7 to 6.4 I lose menu items from my navigation menu if they point to non-Drupal links on my site.

I'm able to reproduce this with a small test site on my desktop. I have no experience with Drupal or with PHP (though I'm an experienced programmer) and so I'm looking for advice on how to troubleshoot this.

I've put print "<!-- ... -->"; statements within this function and run the upgrade, hoping to see the results when viewing the html source in Firefox. However, I suspect the update page refreshes to give the progress bar and completion, so I can't see this output.

Advice please? What methods do people use to investigate upgrade problems?

Comments

drawk’s picture

You could use drupal_set_message to store your debug information in the session's messages var and should then see them when the upgrade is completed. You could also log them to the watchdog table with watchdog('debug', 'your debug message') and then check the watchdog logs.

Just a couple ideas, I'm sure there are other ways too

jwuk’s picture

drupal_set_message() looks very useful if they're displayed afterwards. More generally, how does one use that in other situations? How did you find out about it, any tutorials?

Watchdog, strange choice of name. I would have supposed it related to some timer countdown, not a logging method! So particular thanks for pointing me at it, I would never have thought to look at it. Seems it's superseded in 6.x however. See http://drupal.org/node/300 "Note that starting with Drupal 6.x Watchdog has been replaced by the dblog and syslog modules. Dblog is similar to watchdog; Syslog allows Drupal's logging to be integrated with the server's syslog facility."

Syslog sounds just what I need.

Are these modules part of core? Presumably I can't use them during an upgrade if they're not.

gpk’s picture

>Watchdog has been replaced by the dblog and syslog modules
That is referring to the *module*, but the function call is still there http://api.drupal.org/api/function/watchdog/6.
Basically you learn about this stuff by trying to write modules http://drupal.org/node/508 and browsing the API documentation site http://api.drupal.org/ ... also a book can help http://drupal.org/node/42200.

gpk
----
www.alexoria.co.uk

jwuk’s picture

>Watchdog function call still exists

Ah, good to see some backward compatibility! :) Thanks.

Yes, api.drupal.org is brilliant, kudos to whoever got that going, Doxygen, etc.

Thanks for the pointer to books. Great that Drupal has been so successful that there's a market for books. Though I can't help feeling that, useful though books are, in a way it suggests a gap on drupal.org.

Still, since I'm in no position to fix that, I'd better keep my head down and focus on my immediate problem.

gpk’s picture

>suggests a gap on drupal.org
Books and online docs fulfill different needs IMO. I have the Pro Drupal dev. book for D6 ... it would be hard to get its 600-odd pages of content into a collaboratively edited drupal.org "handbook" unless you paid someone ... Besides, I generally prefer leafing through books to leafing through online docs.

gpk
----
www.alexoria.co.uk

gpk’s picture

Or use Eclipse IDE and Xdebug to debug in real time. Both are free downloads.

gpk
----
www.alexoria.co.uk

jwuk’s picture

Those sound like very interesting things I should investigate. I tried Eclipse (not for PHP) several years ago and ran into no end of problems with issues like different versions of Java, gave it up as a bad job. But I'm sure there's been a lot of progress since.

Can you point to good tutorials, either on or off drupal.org for these? Preferably ones that focus on debugging Drupal, or at least PHP?

gpk’s picture

I had some links somewhere but TBH if you just do a search you will probably find stuff more quickly! Eclipse does have its own way of working and you need to understand that or else you'll get your projects and workspaces in a mess (well, I did!) I found the info about Java versions etc. pretty daunting but actually everything installed very easily and worked pretty well out of the box.

gpk
----
www.alexoria.co.uk

jwuk’s picture

Thanks gpk for your various replies.

I thought I spotted an easier way for my current need in system_install_6021(). I saw that there are various statements like
$ret[] = ...;
so I got smart and added some
$ret[] = "my extra debug";

Tantalisingly it almost worked. In the install report afterwards I'd made a difference but only the first character was displayed!

What's the trick? Do I need to make an array somehow instead of a string? Bear in mind I speak PHP almost as well as I speak Martian. :(

gpk’s picture

Yes, each new element of $ret is itself an array, you would do something like this:

$ret = array(
  'success' => TRUE,  // the 'success' key needs to be there, though probably irrelevant for your purposes!
  'query' => 'Your message here.',  // originally this syntax had "database updates" in mind ...
  )

Possibly you would need to set the 'success' key to FALSE to get the message to appear - not tried it ...

gpk
----
www.alexoria.co.uk

gpk’s picture

You may have noticed that in 6.x you can, as in 5.x, create a menu item in the usual way pointing to an external URL if you specify http:// at the beginning. However, you can't create a menu item pointing to a non-Drupal page on your site. You get an error message "The path 'xxxxxx' is either invalid or you do not have access to it." I've seen an issue relating to the latter part (because it makes it hard to create a custom menu item pointing to user/login), but it looks as though this is a wider regression. Have a search in the issue queue - there may well be something there already. http://drupal.org/project/issues/search/drupal

gpk
----
www.alexoria.co.uk

jwuk’s picture

Surely that sucks for anyone who wants to style internal and external links in a distinctive manner? As many sites do, e.g. Wikipedia. I'm intending doing it myself eventually, though it's a fair way down my list.

OK, I've had a look at that queue now, but I can't see anything (that may be my inexperience though).

I hadn't noticed it in 6.x, I was intending trying this later in 6.x, but not to test its presence, just to get another database dump with 'good' menu_links and menu_router tables to compare with the ones the upgrade is fouling up. It never occurred to me that 6.x actually doesn't work.

Can you tell me where I should go now to get this raised in a fashion that might best get some action?

jwuk’s picture

And now I've found it's not as though this is a need that hasn't previously been seen. See http://drupal.org/node/53857 for a security patch to 4.6 breaking much the same thing. In particular the pain expressed in #4 and #6 of that thread. And #7 needs a good larting, that guy clearly doesn't live in the real world. :(

So I feel confident that this is worth pursuing, other people will benefit as well as me.

gpk’s picture

There's a bit of complexity here it seems. Have a look at #190867: Remove access check for anonymous users when creating aliases. Doesn't seem to be getting much attention at the moment, unfortunately, and all the ins and outs are bit beyond my comprehension :P !

gpk
----
www.alexoria.co.uk

jwuk’s picture

I'm so grateful for your pointer to http://drupal.org/node/190867. I can hardly believe what I'm reading there, this has been known about for TEN MONTHS, yet nobody, it seems, has thought about the implication for all users with non-Drupal site links upgrading from 5.x to 6. Their sites will be silently broken, as mine was.

By the way, how did you manage to track down that discussion? I've had a lot of difficulty with drupal.org's search feature (despite being an experienced user of Google). I wanted to restrict searches by date and other qualifiers, there's such a mass of stuff on this site. However you managed it, it's a useful trick I'd like to learn!

Thank you, gpk.

gpk’s picture

>nobody, it seems, has thought about the implication for all users with non-Drupal site links upgrading from 5.x to 6
Yes and no! The menu/callback/routing system in D6 is basically new and things are bound to slip through the net. The issues seem to impinge on both path module and menu module so it's not a simple fix (or even a simple problem to get in your head, as there are a number of things to consider, and I'm not even fully conversant withthe inner workings of the menu system).

It's unfortunate that in open source development there can be complex niggly problems that don't get much developer attention. Everyone is free to do what they want to fix problems - or not. as in this case, thus far. But I'm sure a fix will come when someone with the relevant experience hits the problem on their D6 site - either not being able to create the menu links they want or losing stuff in an upgrade, as you did. I think roll-out of D6 on large production sites has actually been quite slow, for various reasons.

I'd seen some of the discussion issues before, doing at the link I posted above with terms "menu access path invalid" or somesuch brings up a number of them. I think I also restricted "version" to 6.x variants or 7.x and selected the entire contents of the status select box.

gpk
----
www.alexoria.co.uk

gpk’s picture

If you set up your "external" links as full URLs in the form http://example.com/off-site-page.html then a) they should upgrade OK and b) D6 will treat them properly subsequently.

The only snag with this is of course that you've then got the domain name hard-coded into the URL. Which if you tend to run a dev instance alongside your production site is not ideal. But possibly a workaround for now (provided you don't have too many of them!).

gpk
----
www.alexoria.co.uk

jwuk’s picture

Thanks, but for me not an acceptable workaround for the reasons you mention. My workaround in the very short term is not to upgrade. :(