Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
update.module
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
4 Mar 2009 at 20:56 UTC
Updated:
19 Oct 2009 at 01:30 UTC
Jump to comment: Most recent file
Comments
Comment #1
dwwI wonder why update.module is checking for updates already during install.php...
Anyway, sounds like this is really a bug report against update.fetch.inc's error handling and recovery ("update.module"), not something about update.php ("update system"). Moving to the right component so update_status-enabled folks (namely me, but hopefully others) can find this.
Comment #2
mfbThis also causes cron runs to die with fatal uncaught exception. We just need exception handling in update.fetch.inc. The actual line where the exception is thrown is
$xml = new SimpleXMLElement($raw_xml);Comment #3
mfbParse errors also trigger PHP warnings, so it may not be necessary to do any extra logging. I catch the exception with
break;rather thanreturn;so we move on and try to parse the next XML string.Comment #4
dwwCool, that all sounds reasonable and like a good move in it's own right. However, I'd still like to understand why install.php is triggering an update status fetch, and see if we can just avoid that from happening entirely. Seems like it's needlessly slowing down the installer for something we can do when they finally visit their site.
Really seems like we've got two basically unrelated bugs here: a) install.php shouldn't trigger update status at all, b) update status needs exception handling. We should probably move mfb's nice patch to a new issue just for (b), and leave this issue to work on (a). In the new issue for (b), it'd also be nice to add a test for this, but that should probably wait until #591632: Refactor tests to allow testing contrib lands to avoid patch conflicts...
Comment #5
mfbThis seems quite intentional:
Comment #6
dwwAhh, right, added via #93509: Cron has not run ... hrm. I guess there are good reasons we need that. Alas.
Turns out adding a simpletest for this is basically impossible with our current testing infrastructure. Writing the test itself is no problem, especially now that #591632: Refactor tests to allow testing contrib landed. The problem is that our testing infrastructure provides no way for a test to declare any expected exceptions. As far as the test framework knows, *any* exception is a testing failure. :(
So, until that's resolved, there's really no way to have an automated test that sends in busted XML and makes sure that update.module recovers somewhat gracefully.
Given that, adding some exception handling at all is better than fatal errors on invalid XML, so I support committing this patch now. We can always clean it up in the future, add tests, etc.
Thanks, mfb!
Comment #7
dries commentedThat break statement is a little funny. Normally, as far as normally goes, you'd put more stuff in the try block and have an empty catch handler. Thoughts on that?
Comment #8
neclimdulI don't know, generally you want your try as close to where you're error will be thrown as possible. The break is a little odd looking but the way the try catch is setup makes it clear what error we're catching and the behavior we want associated with that specific error. I do think it would be nice to have a comment telling us why we're breaking out and what the break is doing to the flow.
Comment #9
mfbIt's not documented what SimpleXMLElement::__construct returns if there is a parse error, just that an exception is thrown. So I feel like this is a safe way to handle any exception. I added a comment.
Comment #10
dave reidLooks good. There are too many tiny little conditions that could trigger this and it all depends on valid data from updates.drupal.org, so I don't think this is worth adding tons of tiny little tests.
Comment #11
webchickCommitted to HEAD, thanks.
Might be time to revisit #301005: Add "expected fail" functionality to simpletest so that we can test for things like this in the future?