Running variable-delete on a Drupal 5 sites results in Drush getting stuck in a loop until it runs out of memory and crashes.

The problem is the db_result() function. In Drupal 6, it returns one field and advances to the next row. In Drupal 5 and earlier it simply returns the first field in the first row and does not automatically advance. So trying to use something like while($x = drush_db_result($result)) results in an infinite loop.

I've fixed this be updated drush_db_result to check if the version is <= 5 and in that case to use db_fetch_array to get values out of the query instead.

Eli

Comments

moshe weitzman’s picture

Status: Needs review » Fixed

I reworked this code for a case statement and better coding standards around if statement whitespace and braces. Committed. Thanks.

jaydub’s picture

Status: Fixed » Needs work

I ran into this as well. I backported just the change that was added in commit http://drupal.org/cvs?commit=372162 but that does not fix the issue. The patch above which returns FALSE if there are no results does work. The commit does not include the return FALSE and so the infinite loop continues and out of memory error is returned.

moshe weitzman’s picture

sorry about that. could you make a patch?

eli’s picture

Component: Code » PM (dl, en, up ...)
Status: Needs work » Needs review
StatusFileSize
new402 bytes

Here's a patch that adds the missing return and fixes the problem for me.

jonhattan’s picture

Version: All-versions-3.0 »
Component: PM (dl, en, up ...) » Core Commands
Status: Needs review » Fixed

Commited. thanks.

jonhattan’s picture

Status: Fixed » Patch (to be ported)
StatusFileSize
new617 bytes

@eli: patches are usually done from the root folder of the project. You can get instructions here: http://drupal.org/project/drush/cvs-instructions

Here's a proper patch to backport the fix to 3.x.

eli’s picture

Thanks, jonhatten, I appreciate it. Somehow I always get the easy stuff wrong. :)

kotnik’s picture

Shouldn't the status of this be fixed?

greg.1.anderson’s picture

Technically, yes, this should be 'needs review' since there is a 3.x patch, but please leave it 'patch to be ported' so that it is easier to find when making a 3.x release.

moshe weitzman’s picture

Version: » All-versions-4.x-dev
Status: Patch (to be ported) » Fixed

3.x gets security fixes only.

Status: Fixed » Closed (fixed)

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