Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment | File | Size | Author |
---|---|---|---|
#4 | fast_404-query_expects-1875350-4.patch | 724 bytes | dshumaker |
#1 | 1875350-mysqli.patch | 2 KB | mr.baileys |
Comments
Comment #1
mr.baileysFast 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 bemysql
when using MySQL as backend, and Fast 404 will always use themysql_*
(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
mysql
-branch and always usesmysqli_*
functions (which should resolve the reported issue);Comment #2
soyarma CreditAttribution: soyarma commentedSeems reasonable, patch is applied to 7.x-1.x branch
Comment #3
XerraX CreditAttribution: XerraX commentedI 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.
Comment #4
dshumaker CreditAttribution: dshumaker commentedHmm, 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.
Comment #4.0
dshumaker CreditAttribution: dshumaker commentedupdate findings
Comment #5
adammaloneAs an updated to this issue, a patch to provide PDO support has been provided here: https://drupal.org/node/2078863
Comment #6
jwhat CreditAttribution: jwhat commenteddshumaker is correct, clearly stated in the php manual. I applied his patch in #4 and confirmed.
Comment #7
adammaloneCould 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.
Comment #8
adammalone#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.
Comment #9
adammalone