Problem/Motivation

Recoverable fatal PHP error upon installation due to wrong usage of Drupal 7 API.

Recoverable fatal error: Argument 2 passed to db_query() must be an array, integer given, called in /var/www/sites/all/modules/fast_404/fast_404.install on line 11 and defined in db_query() (line 2313 of /var/www/includes/database/database.inc).

Proposed resolution

See attached patch.

Remaining tasks

Review changes and commit to master branch on git.

User interface changes

Nope!

API changes

Nope!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

protools’s picture

patching file fast_404.install
patch unexpectedly ends in middle of line
patch: **** malformed patch at line 22:

protools’s picture

Version: 7.x-1.x-dev » 7.x-1.3
bensey’s picture

Got the same error also upon install.
This module sounds like it's going to be my web-hosts best friend! Any news on this fix?

skwashd’s picture

Status: Active » Needs work
 function light_not_found_enable() {

The function name should be fast_404_enabled(). That's what is currently in git - see http://drupalcode.org/project/fast_404.git/blob/refs/heads/7.x-1.x:/fast...

Once that is fixed, then this can probably be RTBCd.

Fleshgrinder’s picture

No clue why the name of the function is different in my patch from above. Here’s a new one which hopefully works.

Vacilando’s picture

Damn... even #5 gives:

patching file fast_404.install
patch unexpectedly ends in middle of line
patch: **** malformed patch at line 22:

Vacilando’s picture

Although the patch in #5 does not apply well, after implementing it manually fast_404 installs without a hitch.

Fleshgrinder’s picture

I have no clue why this error occurs.

diff --git a/fast_404.install b/fast_404.install
index 0d972ee..83f167a 100644
--- a/fast_404.install
+++ b/fast_404.install
@@ -4,9 +4,12 @@
  * Implementation of hook_enable().
  */
 function fast_404_enable() {
-  $bootstrap = 1;
-  $weight = -1000;
-  $type = 'module';
-  $name = 'fast_404';
-  db_query("UPDATE {system} SET bootstrap = %d, weight = %d WHERE name = '%s' AND type = '%s'", $bootstrap, $weight, $name, $type);
-}
\ No newline at end of file
+  db_update('system')
+    ->fields(array(
+      'bootstrap' => 1,
+      'weight' => -1000,
+    ))
+    ->condition('name', 'fast_404')
+    ->condition('type', 'module')
+    ->execute();
+}

Line 22 is + ->condition('type', 'module') and this looks okay to me.

kingfisher64’s picture

Can we have the patch in #5 released in a new dev version?

kingfisher64’s picture

Can't use this mod until this issue is fixed. Can someone who knows how to apply the fix either zip the fixed version here or update dev version?

Fleshgrinder’s picture

Version: 7.x-1.3 » 7.x-1.x-dev
Status: Needs work » Needs review
FileSize
633 bytes

Here’s a patch for the development branch of Fast 404. Hope this patch works as expected this time.

Also changed the version of this issue to the development branch as it applies to any Fast 404 version for Drupal 7.

kpearl’s picture

Tested this patch on a clean install that has fast 404 enabled still have this error.

kpearl’s picture

Sorry I figured out that I was getting an error on an environment that I didn't apply the patch too. My apologies! The patch does work.

mr.baileys’s picture

FileSize
627 bytes

Re-rolled the patch since:

  • git apply and patch both complained about the patch being malformed;
  • The patch was rolled against 7.x-1.x-dev, which seems to be a dead-end branch (all versions > 7.x-1.1 have been tagged on branch 7.x-1.x. This is also the reason for the "light_not_found_enabled()"-function name instead of "fast_404_enabled()". Patch here is rolled based on the latter.
mr.baileys’s picture

warmth’s picture

Recoverable fatal error: Argument 2 passed to db_query() must be an array, integer given, called in /home/MYSITE/www/SUBFOLDER/sites/all/modules/fast_404/fast_404.install on line 11 and defined en db_query() (línea 2313 de /home/MYSITE/www/SUBFOLDER/includes/database/database.inc).

Could this be related to Advanced CSS/JS Aggregation fast 404s function or they are safe to work together?

#14 worked for me at least to install/enable the module

batje’s picture

Status: Needs review » Reviewed & tested by the community

patch #14 looks good and works

soyarma’s picture

Status: Reviewed & tested by the community » Fixed

Committed to master, will cut a tag once I get some other bugfixes in.

soyarma’s picture

Status: Fixed » Closed (fixed)

Code pushed, will be in dev branch tonight and upcoming new release

rootwork’s picture

Status: Closed (fixed) » Active

Any chance we could get that new release soon?

webservant316’s picture

when is dev going to be released to the next version?

Scott Robertson’s picture

Issue summary: View changes

This is still an issue in 7.x-1.3, even though it was committed and marked as fixed over a year ago. Is there any ETA on when we might see the next 7.x release?

jdflorez’s picture

I also got the error today when installing it on a D7.22 site with commerce kickstart (7.x-2.6). Can the fix be pushed to a new stable release?

WebWalker3D’s picture

Version: 7.x-1.x-dev » 7.x-1.3

Also getting this issue with latest STABLE release. How can this be a stable release if it can't even install? D7.31 using 7.x-1.3. Fixing this would seem to be a critical issue.

heatherwoz’s picture

Was very excited to try this module and I too received the fatal error upon install. Very frustrating.

Anonymous’s picture

Hi

I have the same error but at diferent line on database.inc (I have Drupal 7.31)

Recoverable fatal error: Argument 2 passed to db_query() must be of the type array, integer given, called in / /var/www/sites/all/modules/fast_404/fast_404.install on line 11 and defined in db_query() (line 2345 of /var/www/includes/database/database.inc).

Agileware’s picture

Receiving this error on a STABLE release does not bode well for new users. Recommend that a new release be issued which is stable or pull the current "stable" release as it's only stable once patched.

jlnd’s picture

Same problem here with fast_404-7.x-1.3.tar on Drupal 7.31.

Recoverable fatal error: Argument 2 passed to db_query() must be of the type array, integer given, called in /var/www/sites/all/modules/fast_404/fast_404.install on line 11 and defined in db_query() (line 2345 of /var/www/includes/database/database.inc).

kevinquillen’s picture

Confirmed. Fresh install got the same error.

Seems like the query should be:

db_query("UPDATE {system} SET bootstrap = %d, weight = %d WHERE name = '%s' AND type = '%s'", array($bootstrap, $weight, $name, $type)); 

But db_update should be used as illustrated above.

adammalone’s picture

Status: Active » Closed (fixed)

Hello, looks like the dev branch has had the code that fixes this issue in for a while. I've cut a new tag for the code that's been in the dev branch for about a year. Watch for the release.