After an upgrade to the latest HEAD, my primary links were lost (i had no sec. links). On top of that, i have two "primary links" menu containers and two "sec. links" containers.

* I disabled all the contrib modules *and themes* as the upgrade tells me to!
* I upgraded using update.php Which broke horribly due to "encoding" collisions.
* I reran the upgrade.php (after fighting with my "back", that was broken by the redirects and JS reloading)
* update.php did not know where it was when it broke (this is an issue I already filed) hence I reran it completely (Joe Schmoe would do the same).
* I now have two "edit primary links" links. Two containers (and the same for secondary links, but that is normal, since I had none before upgrade)

Part of this is due to me running update twice. which is caused by the broken update.php (I still think we should remove the Js from there! I keep running into critical issues leading back to the fact JS is there) Oh, and I used FF 1.0.x (for those that want to tell me that konqueror is broken wrt the drupal JS!)

Another part is due to the update script failing to find my phptemplate settings, which obviously is due to the fct that the theme was not there (as the upgrade tells me to Disable em!)

So how to fix this?
* Remove that JS from update.php (really, it causes nothing but issues). If we insist on Js, then at least we should do it when it a) works and is proven to work b) cannot break on mission critical situations and places (aka update) c) offer a simple and easy way to do it the good ol' way. (I volunteer to rip all the JS from update.php, but not for adding extra layers of complexity to allow people to choose and whatmore)
* Make sure the menu upgrade sees if there already is a primary en secondary links container. if so, make no new one, but add the entries to the existing ones (again, if they exist make no new ones). People can (and thus *are* going to) run update.php twice (if it fails the first time).
* tell people not to disable contribs or homebrewn modules and themes. Which, causes another issue, because they are broken themselves, because they still need to be upgraded. upgrading them, however, is not possible without an up to date DB. Chicken-Egg.

Comments

dries’s picture

I, too, had the upgrade script 'hang' using Firefox. As far as I can tell, the Javascript isn't 100%.

Thox’s picture

I've had troubles with the JS upgrade method in the past (including earlier today). Annoyingly, I've just run a couple of updates on my local machine from 4.6.5 to 4.7.0b4 and then up to HEAD - both without any trouble.

If I have time today then I'll make a patch to strip out all of the JS-related code from updates. Ideally I'd prefer to find what is making things hang or create errors though.

dries’s picture

If we can't fix this timely (before the next beta/RC), we'll take out the Javascript bit.

Thox’s picture

StatusFileSize
new2.42 KB

Simpler than I thought. Attached patch to update.php, and of course you could then remove update.js from misc.

Bèr Kessels’s picture

Title: update does not honour primary/sec links, and breaks in several more places. » update JS breaks in a few places. Strip it for now.
Status: Active » Needs review

I updated one 4.6 and one halfway-HEAD (november) with this patch. Both run fine. All tested on konq. But with this patch the client should not matter :)

A +1 for this patch.

And IMO we should commit a reverse version of this patch to HEAD, after the 4.7 branch is created. It would be a pity to loose this functionality, a lot of effort went into it. A whole release cycle should be enough to get this niftyness in before 4.8, in a better way. (the more because I think 4.8 will be a big JS thing anyway)

dries’s picture

Unless someone comes up with a fix, I'll commit Thox' patch before I roll the next RC/beta.

Richard Archer’s picture

With respect to the menu-related issues mentioned:

- Should update really be telling the user to disable contrib themes? The primary links update requires the phptemplate variables to be available so it can import the old links.

- I don't see that checking for the existence of a "Primary links" menu to be particularly useful. The update script should only be run once... I think it explicitly warns about only running once. So if a user wants to run it twice they can keep both pieces.

Bèr Kessels’s picture

Richard: you are right about the checking for existing primary etc menu's.
"Don't upgrade your database twice as it may cause problems."
We should fix that globally in some future version of upgrade. For people *will* (need to) run it twice if they rat un into trouble on the first hit.

But, as you point out, that is not a menu issue, per-sé.

I will commit that documentation chicken-egg thing to the docs list :) not disabling themes will break non-upgraded themes. Upgrading themes requires an upgraded DB :/

So that leaves us with what the new title suggest: fix the left over JS issues and continue with a hardened upgrade system.

dopry’s picture

Does the JS error reporting patch fix this issue, or at least partially fix it? Can this be split into more specific issues if not? I agree with Ber about the need to keep everything functioning with and without JS. I just don't like the scorched earth remove feature solutions.

Bèr Kessels’s picture

@dopry: no, it does not.

It only solves the result of the problem, not the problem itself. And not always, even.

My point, and that of some others here is, in general, that we need a very sturdy, hardened system in the upload part. We cannot, yet, offer that. So then the best way is, to hold it back (not the same as nuking it!) untill we are more confident about it.

Steven’s picture

There was some off-list discussion of this. I'll just paste my message here:

I've developed several (multi-part) updates, each time using the Javascript version to develop and test. I've never encountered a hang that was not caused by faulty code in my particular update. And since then I've committed a patch which fixes the lack of feedback when the update polling fails, whether it be due to PHP errors or transfer errors. So you will never get an indefinite hang (at most until the PHP time limit, or the TCP/IP timeout).

The JS update path is not voodoo magic. It simply makes the update polling asynchronous for the end-user. If the JS version hangs, then the non-JS version hangs too. Thox's removal patch shows how little effect the JS has on the update system.

As far as testing goes, you can do short test runs if you add some bogus updates that consist of sleep statements (to ensure multiple requests are needed to finish). You can manually force updates to run again using the schema dropdown in update.php. Unless you actually want to test the 4.6-4.7 updates themselves, then it doesn't matter because, whether Javascript is used or not, the updates are performed exactly the same way.

To be honest, I'm sick and tired of anti-JS FUD. Like with any other feature in Drupal, we can only fix problems if there are proper bug reports which allow reproducing the bug. If we cannot reproduce, then we should "won'tfix", and not "ripoutthefeaturebecauseit'seviljs". Anecdotal reports of "having the update system hang" are useless.

Bèr Kessels’s picture

No one is spreading JS FUD. Not in here anyway. We are trying to solve a bug. A problem.

we should be fair, and admit that there is hardly a JS developers base in Drupal. if there is a problem in PHP we can all solve it. Or at least get to the core of the problem. We simply lack the workforce to do the same wih JS.

Example: If I were to release Drupal scripts or toolkits written in Ruby, that have a bug, or missing feature, how can I expect the PHP developers using it, to "send in patches, not reports"?

I know there is an issue qwith the upgrade. I know that others ran into the same issue. That is a fact.
But I lack the JS knowledge to fix it. Does that make the bug less valid? Does that suddenly mean the problem is gone? Or that we should ignore (wontfix) It? Till now, the only solution that fixes this rather critical bug of "hanging upgrades" is presented by Thox in a patch that removes the JS for the time being.

JS is not evil. No-one has said so. JS has problems. and difficulties. Like any technical system. But when we cannot overcome those problems and difficulties, the best solution is to not go into that area. Or to train workforces that can use it.
We are doing that latter now; but it seems they are not up to speed, at least I am not. so untill we have people to actually fix the issues that arise, we should avoid getting these issues in the first place.

chx’s picture

Ber, what Steven says is that JS is *not* the cause of update problems which I tend to believe.

I am no JS guru. But I was writing a chat program for my own needs with xmlhttprequest years before anyone has called this ajax. I do not pretend to be able to write the nice behavioral js Steven & Thox produced. But I understand it pretty well, and it would come to me a big surprise if it would cause "hang". Do not strip the JS as it's very useable.

Bèr Kessels’s picture

Okay now we are getting somewhere:
And here is what i did and what happened:
* I ran updates with konq. It hung, I though "well, its prolly one of those annoying Konq only issues." rightclick > open in > Firefox
* I ran updates with Firefox. It hung. I was flabbergasted. (and had two primary menus by now)
* Switched *off* JS in konq and ran the updates again. With a backup. It ran fine. Some SQL errors and warnings. But It finshed.
* Switched *ON* JS in konq and ran the updates again. It hung. But I found not one JS error. Not in the (very powerfull!) JD debbugger, nor in the normal JS error logs.

Again: I have no clue what, how and why. I do* know tat thox' patches fixes it. And I do know that I am not the only one with hanging issues.

So, what to do? How can we dig deeper? Do we want to dig deeper? Untill I see another patch that fixes the hanging issue, I will continue to support the *only* patch that appears to fix it. And frankly, I am not really motivated enough to dig much deeper. I have more important bugs to fix. That itch me harder. I can still just switch off JS in konq. And I am sure there is a toggle for this in FF. But beware of he flood of supp. questions :)

moshe weitzman’s picture

Title: update JS breaks in a few places. Strip it for now. » update JS breaks in a few places.

removing the submitter's proposed (non) resolution from the bug report. a description of the bug is all we need there.

dries’s picture

Ber: could you provide a copy of your database/site for Thox/Steven/anyone to play with? Looks like you have a backup that allows us to recreate the problem. Anything particular in your watchdog? Any 'headers have already been sent' messages? Can you try again with full error logging? Looks like you're the key to have us investigate this some more.

Steven’s picture

I don't understand why you would have a problem by running update.php twice though. After each update, the following code is run:

function update_data($module, $number) {
  ...
  if ($finished == 1) {
    drupal_set_installed_schema_version($module, $number);
  }
}

The menu update is not a multi-part one, so it will always finish in one call. Running update.php again should not mess things up, unless you manually force the schema version to an old one.

eaton’s picture

I've got a 4.6 database sitting around that I've been meaning to update. It's backed up, so I can attempt upgrades, botch, and restore endlessly if necessary.

At present, I get a cascade of errors just hitting update.php.

Warning: Illegal mix of collations (utf8_general_ci,COERCIBLE) and (latin1_swedish_ci,IMPLICIT) for operation 'like' query: SELECT * FROM access WHERE status = 1 AND type = 'host' AND LOWER('69.209.91.222') LIKE LOWER(mask) in /home/viaposit/public_html/includes/database.mysql.inc on line 120

Warning: Illegal mix of collations (utf8_general_ci,COERCIBLE) and (latin1_swedish_ci,IMPLICIT) for operation 'like' query: SELECT * FROM access WHERE status = 0 AND type = 'host' AND LOWER('69.209.91.222') LIKE LOWER(mask) in /home/viaposit/public_html/includes/database.mysql.inc on line 120

... are the important ones, everything else is just cascading 'headers already sent' stuff. If I persist in upgrading, it tells me to start at System update 129. After a few seconds, a Javascript window pops up with an impressive list of errors also revolving around those same two queries. Rinse, repeat. I'm sure others have had the same problem, but I wanted to chip in and see if there's anything I can do to help.

eaton’s picture

...And, I ran the patch and the update process works. It's not as pretty as the JS version, but it does work. And that makes me happy.

dries’s picture

Eaton: so the JS upgrade system doesn't work and the non-JS one works?

eaton’s picture

Dries: Just spent some quality time restoring and upgrading a 4.6 database over and over. What I've found is:

For MY database (can't speak of any others) the abovementioned SQL errors appear as soon as I hit update.php. If I persist and launch the update operation using the current cvs version of update.php, it chugs along for a bit, then throws a javascript dialog up with a page of SQL and output errors relating to collation problems.

IF I go back to update.php from scratch, it starts where it left off. It continues throwing javascript popup errors, though, and I'm not sure if it's actually making progress.

If I use the patched non-Javascript version, the same underlying errors seem to happen, I just never get the Javasript popup window. When the non-JS version 'halts' (around update 146 in this case) it just sits there with two SQL errors on the page and doesn't continue reloading/executing subsequent updates.

It appears that going back and starting the update again -- and ultimately succeeding -- works with the non-JS version. I have to go through a few more restore/update/restore/update/etc cycles to be sure.

eaton’s picture

StatusFileSize
new444.08 KB

I've attached a full backup of the pre-update DB for others' troubleshooting/testing fun.

killes@www.drop.org’s picture

eaton: does this happen always on update 146?

dopry’s picture

After speaking with eaton on IRC, we figure out his problem is an update issue, and the JS error reporting seems to be functioning properly in his case.

I would say for the most part none of the issues in this thread are directly javascript related. Javascript/Ajax hinders debugging, and is far less straight forward than the typical GET/POST http scenario.

I think the new javascript error reporting will ease a lot of the hinderances AJAX causes with the debugging process.

Nearly all of these errors I think are directly related to the update system, and errors in the system_update_n function.

The system_update_n functions are atomic per update_n hook, but what about within the update. I see multiple alter queries in a many system_update_N functions. In a case where the first few queries suceed and a latter fails the update won't be marked as complete and will be re-attempted... re running some updates could have destructive effects if an early "transaction" wasn't completed.

I think this js issue should be closed outright, and proper issues against the update system be opened.

eaton’s picture

killes: after investigation, it appears dopry's analysis is correct. Javascript isn't the source of any of these issues, it just muddied the waters a bit.

dries’s picture

Title: update JS breaks in a few places. » JavaScript updater confusing when update path has bugs/warnings

Even if the analysis is correct, and the JS isn't the source of the problem, it managed to confuse you more than it should. It took you a few attempts to realize and validate that everything is OK. Something you, as a developer, can do. Certainly not something Joe Average will manage to investigate and grok.

Soon there will be up to 50.000 Drupal websites that might attempt to upgrade; the process should not be confusing, nor frustrating. Let's try to fix the broken update so it's no longer confusing. We now have a test database to play with.

If we can't fix the broken upgrade, we might still have to remove the JS for reasons explained in the first line of my comment.

Bèr Kessels’s picture

Finally we seem to get to my first point:
It does not need to be the JS that causes the issues. It does not matter if it is the JS causing it, the PHP or the upgrade or (in my case) a broken database.

It is the fact that javascript'breaks' on this breaking of the upgrade. is anything goes booboo (and beleive me, a lot of things go booboo in the upgrade) then the JS breaks far too often too. Resulting in either a hanging progressbar, or in a popup with all the errors in it.

My point, all along was, that we should stick to the most sturdy system, in a critical place like the upgrade.

I know it is nifty to have a progressbar. I know it is nice to show off some AJAX. I know it enhances usability a lot, by hiding ugly stuff from users.

But if that means that my broken database cannot be upgraded, if that means that a lot of upgrades will 'hang' or else produce funny results, then please lets remove it, untill we have it as sturdy as the rest.

@dopry: Solving all the update problems is unrelated to this. We know one thing for sure: no-one has the same database. No one. And I know for sure that an incredible lot of the upgrades will give errors on an incredible lot of peoples systems.
so even if we solve all our core update problems (which we should) then still: errors will occur.

killes@www.drop.org’s picture

I tried to upgrde eaton's database and got this error:

Failed: ALTER TABLE {vocabulary} ADD tags tinyint(3) unsigned default '0' NOT NULL

Everything else went fine.

I think I hate backported features with db changes.

dries’s picture

Killes: did that cause your Javascript upgrade to hang/choke? What did you experience?

killes@www.drop.org’s picture

I had tried without JS. Now tried with JS and it went through.

I got "user warning: Duplicate column name 'tags' query: ALTER TABLE vocabulary ADD tags tinyint(3) unsigned default '0' NOT NULL in /home/killes/checkouts/drupal/includes/database.mysql.inc on line 120."

Printed on the screen, but this might be due to the debugging uptions in settings.php that I used.

Steven’s picture

StatusFileSize
new12.17 KB

The only problem I have with updating the database dump higher up is when PHP's display_errors is set to TRUE. In that case, the UTF-8 Collation warning messes things up for JS, because it is output before update_do_update_page() can surpress all error reporting.

IMO we should simply always hide all errors (by moving the ini_set('display_errors', FALSE) to the beginning of update.php:

  • Without it, the utf-8 collation and watchdog referrer errors show up on the update.php Access Denied page, possibly confusing users (no update_fix_foo() is run in this case, and even if they would run, the errors still show up the first time).
  • All errors are logged to the watchdog and shown at the end of the update process anyway.

Patch attached for this. Though it also hides the collation error, I added an explicit fix for it anyway, as this is the best solution. I can complete the update process on the faith.gz dump, though there is a message at the end about a failed update.

Now because the main issue here is user confusion, I took a closer look at what happens if a fatal error occurs. Neither the JS nor non-JS version is clear: an alert box in the former, a white page with error message in the latter (but only if php.ini error reporting was set to true, which is not the default, otherwise you get a blank page). So I altered the JS so it redirects to an error page, and I used an output buffering trick to achieve the same in non-JS.

So now, they both do exactly the same and recover from fatal PHP errors in a user friendly manner.

drumm’s picture

I like UnConeD's approach to fixing this issue.

Steven’s picture

Status: Needs review » Fixed

Committed to HEAD.

m3avrck’s picture

StatusFileSize
new2.27 KB

So this evening, Matt and I were updating Participate.net when we got the dreaded infinite database loop. Nothing seems to happen, never gets to 1%. If you look at the database, access table is updated to utf8, but that is it.

You can start and stop but nothing. Then it was going the 2nd time and we got this error after a few min:

'An HTTP error 404 occured'
update.php?op=do_update

Strange. So then we apply Thox's patch and Matt modifies it slighty to apply to HEAD and magically, everything works. But strangely enough, I *didn't* refresh my browser cache, but instead reran the page, and the JS updater worked great this time around.

*Very* strange. Was it the patch that did it? If so, I didn't refresh my cache so none of those JS updates were ever applied, only the ones to update.php were.

If not, was it just 3rd time is a charm type luck?

Who knows, but upgrading is a bit of a headache. However, I've encountered this infinite loop before, but no corrupt data so far, mostly just puzzlement. And then it just works.

However, Steven, great patch, no more long lists of collation errors :-) That's a great start!

m3avrck’s picture

Oh wait, this patch never touched update.js. Hmm, perhaps the key to fixing this infinite loops lies somewhere in this attached patch, because everything did work after applying it.

Much too tired to analyze it anymore tonight though.

Bèr Kessels’s picture

Status: Fixed » Active
drumm’s picture

Status: Active » Fixed

Restoring old status.

dries’s picture

Status: Fixed » Active

I agree with Ber. It seems to be the number one thing people are complaining about at http://drupal.org/drupal-4.7.0-beta5. Until we can easily reproduce the problem, there is little we can do. We'll need someone to deliver a (new) database dump that we can use to reproduce the problem.

drumm’s picture

I suspect that browser caching of js files from the older version has something to do with this. Please try to collect the following information from anyone with these problems:

-Browser/OS version
-PHP Version
-PHP error handling settings (listed at http://www.php.net/manual/en/ref.errorfunc.php#errorfunc.configuration)
-Drupal error handling setting
-Try clearing your browser's cache, going back to a backup if one exists, and trying again.

Remember that the update script changes the internal version number after each update it performs, so it is harder to perform the same update twice.

Bèr Kessels’s picture

@all: The problem is not with a specific database issue. It does not happen with a specific error in the DB.

The problem can be easily reproduced: Any database, with Any Error, PHP, MySQL, etc, that sends a header, will make the progress bar halt. Any critical error will do the same. There are a LOT of methods to break the upgrade and make it "hang"
* Try: deleting a critical table
* Try a print 'w000t'; anywhere (update.inc)
* Call an undefined function.
* Run anything, slightly, broken on an envireonment where the ini_set cannot change the error level
* Any combination thereof.

I have managed to make it "hang" on nearly all of these. And some combinations made the error reporting work again, while others did not.

The problem, *as I see it*, is not per-se *caused* by JS. It is just that existing problems are very much obfuscated by that JS. We do alert() people; we do try to catch the outputted headers off. But that is never as sturdy as plain old PHP printing screens full of errors (that are copy-pastable into a search, above all!). That, is the underlying issue under all the issues that mention 'hanging' updates.

PHP, thje goold old fashioned one, has basically two modes: Errors on, or Off.
In case of the first, the users will be scared by all the stuff shown, but anyone running a drupal site is IMO able to copy paste these into a search.
The second mode is harder. In support I have lead many people by the hand to a) support of their server, to get the error logs, or get the error reporting switched on and b) to the error logs themselves, in 90% to find out that some ugly, old or FuBarred module was acting weird.

By introducing the layer of JS, we add a lot of complexity to that rather simple model above. That, I have to add, is my only problem with the JS in update.php. The fact that we are adding a lot of complexity, in a place where IMO stuff should be as streightforward as possible. I have to add also, that I really have nothing against JS or AJAX, eventhough my various posts may let people think so. My problem with JS, is that it most often breaks things (for a small group) rather then making the simpler (for a larger group). I have a lot of experience with plesk. And I will fight with my toe-and-fingernails to peevent Drupal from becoming a plesk-alike 'thing' :). This, also, i want to stress, does not mean i do not value all the enormous effort for these JS and userfriendly upgrades. I love the improvements, the hardcore stuff thatis done inbetween. I just still see the contras overshadow the improvements and pro's.

Hence I would like to plea again, that we should consider working out this issue in the longer road towards 4.8, and not in the critical path towards 4.7. The JS might not be the cause of the trouble, it is at least making them far worse then they could be. So, I plea, for postponing the addition of JS updates, untill we have them really sorted out.

moshe weitzman’s picture

It would be easy to attach a time() timestamp to the javasript incldue in the updater just to make sure that everyone has the latest. this is an acceptable performance hit IMO because updating is so rare.

moshe weitzman’s picture

I meant append a timestamp on the querystring thus forcing redownload of the js

Steven’s picture

Bèr: I disagree that the JS adds complexity. It simply adds a different, more elegant polling mechanism (ajax with HTTP POST) in place of a very outdated and inappropriate one (meta refresh with HTTP GET). All the complicated actions happen on the PHP side. The obscuring is very, very minimal. Anyone who knows PHP should be able to make sense of JS code. You know Ruby as well, so you have an extra edge.

The main problem with the JS was strange error reporting in the update system. Fine, I fixed that. All it took was someone to analyse the PHP error reporting from a neutral perspective. Your last comment seems to indicate that you already knew of these issues before. If you then chose "remove the update JS" as the answer, then you are not thinking from a "I have nothing against JS" perspective IMO. Especially considering that the non-JS version used to have much worse usability issues than the JS version (blank screen if display_errors was set to Off and a fatal error occurred).

As far as your list of methods of 'breaking the update' go, the update system in HEAD recovers gracefully for all of them (so you are definitely not using the latest). Still, I think that any update which calls non-existant functions or prints out crap is broken and needs to be fixed. The only issue is if ini_set does not work, but in that case settings.php will throw errors anyway. It is IMO an unsupported configuration.

dries’s picture

The update.php is not properly reporting errors anymore. I spent 45 minutes debugging a simple problem.

Update.php said: 'The update process did not complete. All errors have been logged. You may need to check the watchdog table manually.' but no errors were logged.

jadwigo’s picture

Updating from 4.7beta4 to 4.7beta5 the updater javascript seems to hang..

The FireBug extension reports the following responseText came back
{ status: 1, percentage: 100, message: "Updating complete" }
But immideately after that it reports "parseJson is not defined" in progress.js on line 89.

This only happens when I upgrade on a server that is far away (as in not on my local network) .. on the local network it just works(TM)

By the way, to debug AJAX Firebug is invaluable.

dries’s picture

Might be related or similar to a problem I had: http://drupal.org/node/13148#comment-79277. Javascript reported an "unspecified error" because of PHP error that was surpressed. Removing ini_set('display_errors', FALSE) from update.php helped me debug the problem (but might screw up the updater). Removing that line worked for me.

Steven’s picture

If you get a parseJson not defined, then your browser is definitely caching an old JS file. That function is defined in drupal.js, which all other JS files depend on, including all the code before that in progress.js.

dopry’s picture

Summary:

  1. errors in update hooks play havoc with the upgrade process.
  2. Javascript makes debugging difficult for some developers.
  3. old javascipt source files are cached on the browser
  4. ini_set(display_errors, 0) messes with the Javascript and hides errors.

Suggested Solutions:

  1. file bugs against the update system
  2. use firebug, or read the error message and goto 1
  3. add a ?$timestamp to the url for the javascript in update.php
  4. Our Ajax library needs to report that php execution failed due to a fatal error, and possibly report that error in place of ini_set(display_errors, 0).

I still don't see that JS is a problem. I think the remaining bugs are still primarily in the update system, political/personal, with our Ajax implementation(particularly the error reporting), and good old browser caching which has plagued web developers for all time.

I'm going to split this issue into several distinct issues once I get to my office. And maybe we can close some parts of it instead of having several issues buried under the rather abstract title of "Javascript is Confusing".

.darrel.

dries’s picture

Good summary, Darrel. Good idea to split the issue in smaller (critical and non-critical) problems.

dopry’s picture

Status: Active » Fixed

I wish there was a split to other issues status, but fixed will have to do.

Anonymous’s picture

Status: Fixed » Closed (fixed)