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.
Hello,
This task is intended to store the ideas of improvement of the module. When you see anything you think it will improve the module (documentation needed, coding style, refactoring, ...) post a comment or edit the issue body.
- Using the Drupal API to avoid database requests using MySQL
- The functions protected_node_enter_any_password (protected_node.fork.inc) and protected_node_enterpassword (protected_node.redirect.inc) have a lot of code in common (which also should be cleaned)
Thanks.
Comment | File | Size | Author |
---|---|---|---|
#18 | using_database_api-2146795-18.patch | 20.67 KB | Grimreaper |
#15 | using_database_api-2146795-15.patch | 20.63 KB | Grimreaper |
#13 | using_database_api-2146795-13.patch | 15.75 KB | Grimreaper |
#10 | using_database_api-2146795-10.patch | 16.39 KB | Grimreaper |
#7 | using_database_api-2146795-7.patch | 16.68 KB | Grimreaper |
Comments
Comment #1
GrimreaperImplement the automated tests ?
Comment #2
GrimreaperHello,
Here is a patch which rewrite the sql queries to use the database API.
I don't have rewrite a query which in the protected_node.install file because it is commented.
Warning : I don't have tested the patch yet (no time), I have just written it
Thanks for the test and the review.
Comment #3
GrimreaperI forgot a lot of db_query as there was not a @todo tag near them.
WARNING : the patch is not operational. It's introduce errors.
Comment #4
GrimreaperShould be tested, I have no more crash on basic usage and the admin page works.
Comment #5
GrimreaperComment #6
cashwilliams CreditAttribution: cashwilliams commentedpatch needs a re-roll
Comment #7
GrimreaperEffectively, thanks for pointing it.
Should be usable now.
Comment #8
izus CreditAttribution: izus commentedHi,
Thanks for providing the apatch
i would prefer some input from other users but we can't always get what we want !
i tried reviewing the patch and here is the result.
actually this hook is a Drupal 6 one, it should be replaced by https://api.drupal.org/api/drupal/modules!system!system.api.php/function... from Drupal 7
request will not be successful, the methode name you want here is fields (with s)
request will not work. the method name is fields not field
This doesn't seem to work.
you may want to combien a db_select and db_insert as in https://drupal.org/node/310079
or maybe use a db_query
Comment #9
izus CreditAttribution: izus commentedComment #10
GrimreaperThanks for the review.
1. In my patch I comment it, in this patch (10) I simply delete it. So ? I need to implements hook_query_alter ?
2 and 3 : OK, I found a third place where I miss the "s".
4. OK.... I tried your proposition, but it seems strange. I don't test it.
Comment #11
izus CreditAttribution: izus commentedyes we need a hook_query_alter to do the same logic as drupal6 version.
for 4, you can try the two versions sql resquest via devel/php for exemple. we can in addition check if $query doesn't return anything and how it will behave with db_select
Thanks
Comment #12
izus CreditAttribution: izus commentedComment #13
GrimreaperI tried to implements the hook_query_alter, I don't see how to reproduce the d6 logic, and I think we don't need it.
Protected_node_db_rewrite_sql is no more executed in D7 and I think we would have more bugs reported if it was needed.
So in the last patch, I keep it in the same state as the last code rebase, and I think we will see it later. I don't want the whole patch to be blocked for this hook.
4. I decompose in small steps because I had errors all the time, even with the previous implementation. I know that is not optimized, and I will be better in using the batch API. But it works.
Thanks for the review.
PS : and the previous patch needed to be rebased. :)
Comment #14
izus CreditAttribution: izus commentedoki let's do the following :
1) create an issue where we focus on the hook_query alter thing to digg more wheather we need it or not
2) rebase this last path as it seems good but needs a rebase
3)for the sake of progress we merge it and keep progressing :)
Comment #15
Grimreaper1) done
2) done
3) ok, in the future, I think I will prefer making shorter patches :)
4) warning : in protected_node.module, there were two db request wrong, one in protected_node_and_attachment and the other one in hook_file_download. Two request with a lot of joins, now it should be good. About the one in protected_node_and_attachment, it took me time to realise the tables no more exists in D7, as you made in your patch on the bug on private files.
Now it should be good, but I prefer to warn, if you want to check another time.
5) searching for 4), I discovered how to use count directly in the db request, used in the admin form for stats.
Thanks for the review.
Comment #16
izus CreditAttribution: izus commentedfu.id can target something else than a node, it can be any entity type, we should filter of node in the 'type' colum of file_usage table
Comment #17
izus CreditAttribution: izus commentedComment #18
Grimreaper$query->condition('fu.type', 'node'); added
Comment #19
izus CreditAttribution: izus commentedmerged
hope this has no bugs in it, i reviewed it each time but guess this is not sufficient for such a change, we lack testing-focused people.
Thanks !