Hi,

I receive this warning when visiting valid pages, just a thought will it be better to follow the drupal way to use db_query instead of mysql_query?

Warning: mysql_query() expects parameter 1 to be string, resource given in fast_404_validate_path_mysql() (line 189 of /***/sites/all/modules/fast_404/fast_404.inc).
Warning: mysql_fetch_row() expects parameter 1 to be resource, null given in fast_404_validate_path_mysql() (line 189 of /***/sites/all/modules/fast_404/fast_404.inc).

Thanks!

Update: Only happens if fast_404_path_check() is uncommented

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mr.baileys’s picture

Version: 7.x-1.3 » 7.x-1.x-dev
Status: Active » Needs review
FileSize
2 KB

Fast 404 currenctly tries to switch between mysql and mysqli by checking $databases['default']['default']['driver']. However, for Drupal 7, which uses PDO, this value will always be mysql when using MySQL as backend, and Fast 404 will always use the mysql_* (as opposed to mysqli_*) functions under D7.

Given that there is little difference with regards to performance between mysql, mysqli and PDO, and that mysqli is preferred when using MySQL +4.1.3 (D7 requires 5.0.15), I suggest dropping the mysql-branch altogether in favour of the mysqli-branch. Alternatively or later on, the function can be rewritten to use PDO, which would allow it to work with non-mysql backends too.

Patch attached that

  • Drops the mysql-branch and always uses mysqli_* functions (which should resolve the reported issue);
  • Sets the default mysql port to 3306 if not given (mysqli_connect fails when called with $port = '');
soyarma’s picture

Status: Needs review » Closed (fixed)

Seems reasonable, patch is applied to 7.x-1.x branch

XerraX’s picture

Status: Closed (fixed) » Active

I ran into this issue because my server can only use mysql and not mysqli. The "improved" version causes restarts on my server for some reason i cant find.

So i suggest to rethink this decision. There maybe others with the same problem.

dshumaker’s picture

Status: Active » Needs review
FileSize
724 bytes

Hmm, well according to this page:

http://php.net/manual/en/function.mysql-query.php

All that needed to be done was switch the parameters around. I did that and all is well on this end.

attached patch.

dshumaker’s picture

Issue summary: View changes

update findings

adammalone’s picture

As an updated to this issue, a patch to provide PDO support has been provided here: https://drupal.org/node/2078863

jwhat’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

dshumaker is correct, clearly stated in the php manual. I applied his patch in #4 and confirmed.

adammalone’s picture

Could we perhaps get more eyes on #2078863: Provide PDO db access in fast_404_path_check [patch attached]? The work done over there encapsulates this change and should fix any issues experienced that arise from this. Now that I have commit access, I'm likely going to add that patch, although since it was written before I gained that, I'd appreciate others who were using fast_404 in a different manner to me to give it a once over.

adammalone’s picture

#2078863: Provide PDO db access in fast_404_path_check [patch attached] has been committed which should mitigate this whole issue entirely. Please upgrade to the latest dev of fast_404 to use this.

adammalone’s picture

Status: Reviewed & tested by the community » Closed (duplicate)