The fix for the core bug reported in #1143460: hook_file_download_access_alter missing entity argument is taking a different, and better, approach then I originally suggested. I'm hopeful we'll get that bug fixed soon and download_count updated correctly.

However, in the meantime I'm going to keep this issue updated with whatever current patch is required to use the 7.x-3.x version of download_count.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

WorldFallz’s picture

Issue summary: View changes

correct punctuation

famous’s picture

there is no f*****g description anywhere to install this f****n patch!!!!

[edited to remove foul language]

WorldFallz’s picture

1. lose the foul language
2. it's mentioned right on the project page

CWz’s picture

Category: bug » support
Priority: Critical » Minor

I'm running on a shared host with no ssh. how do I apply the patch manually?

WorldFallz’s picture

i'm not really sure-- you need to be able to edit the file and make the changes. Maybe do it locally and then upload load it however you install stuff without ssh.

Mekhet-1’s picture

Hi WorldFallz

for the life of me i cannot find anywhere on how to install the patch. I've checked the project page. Probably just an id10t error. Can you please assist

Thanks

WorldFallz’s picture

That's not a module specific thing, see http://drupal.org/patch/apply.

lukus’s picture

Is there a new patch available for 7.14?

yurg’s picture

For D 7.14 please try attached one.

robwithhair’s picture

#8 worked for me.

warmth’s picture

7.15 needs this patch?

yurg’s picture

re: 7.15.

Yes, had to apply it after update.

WorldFallz’s picture

yep-- until the bug is fixed in core d7 (it's not even been fixed in d8 yet and that has to happen first), this patch is required. Believe me-- as soon a fix has been committed I'll update this thread!

chirhotec’s picture

Updated for Drupal 7.16

ANDiTKO’s picture

Im getting

error: patch failed: includes/module.inc:909
error: includes/module.inc: patch does not apply

In Drupal 7.16 for patch #8.

destinationsound’s picture

can anyone be nice enough to zip up their patched module's folder and attach to this thread the ones who do not or cannot patch can access this module? thanks!

ANDiTKO’s picture

Applied patch #13

Here is the patched module.inc file for Drupal Core 7.16 +

Replace this module.inc with "includes/module.inc" and use it at our own risk.

adammalone’s picture

FileSize
906 bytes

Here's a rerolled patch for 7.16. I've checked resetting drupal to 7.16 HEAD and applying the patch again - cleanly applies.

Try this over another module.inc as it can be reapplied as necessary. This patch is probably the same as the one above but perhaps it will apply to your install.

idefix6’s picture

Is there a chance to get this patch integrated into drupal?

warmth’s picture

So bad that 7.17 came out without it...

adammalone’s picture

There is another issue for getting that patch into drupal over here: http://drupal.org/node/1143460

toxiclung’s picture

#17 worked for me on 7.17
subscribing...

alfaguru’s picture

Rather than requiring this patch, given that file.module always calls hook_file_download_access immediately before hook_file_download_access_alter, could you not save the extra parameter in a hook_file_download_access implementation then retrieve it in the alter step?

Eg:-

<?php
function download_count_file_download_access($field_item, $entity_type, $entity) {
 $saved = &drupal_static('download_count_file_download_access', NULL, TRUE);
 $saved['entity'] = $entitity;
 return array();
}
function download_count_file_download_access_alter(&$grants, $file, $entity_type) {
 $saved = &drupal_static('download_count_file_download_access');
 $entity = $saved['entity'];

 ...
}

?>

Not very pleasant, I admit, but I feel it's better than requiring a core patch.

WorldFallz’s picture

yeah-- I wanted to avoid that ugliness when I had hope that such a simple bug would be fixed pretty quickly, but given it's now almost 2013, I guess that plan is moot, lol. I'll try to roll a new snapshot with this fix this week.

adammalone’s picture

The patch is RTBC in #1143460: hook_file_download_access_alter missing entity argument - I think a core committer just needs poking to review and commit.

spencerthayer’s picture

Now I am having problems related to this error. It started after I carelessly did an update. Crap.

This has been a problem for a while. How come this patch hasn't been committed into the main branch? It's 2013 now.

<blockquote>Warning: Missing argument 4 for download_count_file_download_access_alter(), called in /var/www/DOMAIN/includes/module.inc on line 1056 and defined in download_count_file_download_access_alter() (line 149 of /var/www/DOMAIN/sites/all/modules/download_count/download_count.module).
Notice: Undefined variable: entity in download_count_file_download_access_alter() (line 191 of /var/www/DOMAIN/sites/all/modules/download_count/download_count.module).
Notice: Trying to get property of non-object in download_count_file_download_access_alter() (line 191 of /var/www/DOMAIN/sites/all/modules/download_count/download_count.module).
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'id' cannot be null: INSERT INTO {download_count} (fid, uid, type, id, ip_address, referrer, timestamp) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6); Array ( [:db_insert_placeholder_0] => 56 [:db_insert_placeholder_1] => 30641 [:db_insert_placeholder_2] => node [:db_insert_placeholder_3] => [:db_insert_placeholder_4] => 38.104.99.170 [:db_insert_placeholder_5] => http://DOMAIN/PATH/title [:db_insert_placeholder_6] => 1357140408 ) in download_count_file_download_access_alter() (line 196 of /var/www/DOMAIN/sites/all/modules/download_count/download_count.module).
Recoverable fatal error: Object of class stdClass could not be converted to string in template_preprocess_maintenance_page() (line 2710 of /var/www/DOMAIN/includes/theme.inc).</blockquote>
WorldFallz’s picture

David_Rothstein FTW: #1143460: hook_file_download_access_alter missing entity argument.

So, there will be no workaround release.

Once drupal 7.19 is released, I'll do a quick test to verify everything works and finally finally finally roll an official release of download_count for D7!

warmth’s picture

Those are great news!

herbiek’s picture

Yess! Finally, waiting for this a long time. Thank you!

herbiek’s picture

Drupal 7.19 is out! Whats the next step?

adammalone’s picture

As was mentioned in #1143460: hook_file_download_access_alter missing entity argument since 7.19 is security only, this patch will appear in 7.20.

haydeniv’s picture

FYI: http://drupal.org/documentation/version-info

When is the next release?

New stable releases of Drupal core are scheduled to occur within particular release “windows“:

A bug fix release window is on the first Wednesday of each month.
A security release window is on the third Wednesday of each month.

A release window does not necessarily mean that a release will actually be made on that date, but it exists so that site administrators can know in advance which days they should look out for one.

So the earliest that patch will be in core is Feb. 6.

gChen07’s picture

Is there any update regarding this module.. I am using D7.17 and I tried using the 7.x release and patches but as with everyone applying patches is very confusing and I am also afraid that I might ruin the site due to fatal error messages I am dealing with most when I add or delete module.. so I decided to wait for the formal release of this module.. I am creating website for compiling electronic thesis and dissertation where this module really helps to track research utilization as well as abuse in downloading. Thanks in advance..

gChen07’s picture

@#21
What patch did you use.. and how did you installed it

chirhotec’s picture

Maybe we could include this patch into the Fix Core module?

"This module collects various fixes to core issues that have not been implemented yet. By default, all of these fixes are disabled, and you can enable them one by one."

That way, any time we upgrade core, we just need to update that module, and those unfamiliar with the patching process have an easy solution.

warmth’s picture

That's a great idea.

adammalone’s picture

Actually not the best idea - it's already in Drupal 7-dev so should be released with 7.20 sometime in March!

WorldFallz’s picture

Yep I agree with typhonius-- the fix could be released by the time the patch is created and accepted for the fix core module and would therefore require yet another patch to fix core to remove it.

That said however, it's entirely up to whoever wants to create the patch for fix core and the maintainer of the fix core module.

adammalone’s picture

Correction - 7.21 since 7.20 was released today and is a security only release

Kaese’s picture

Is this patch now rolled out in 7.21 or has it been delayed again since this release was merely a bugfix for 7.20?

warmth’s picture

Drupal 7.21, a maintenance release which fixes incompatibilities introduced in the Drupal 7.20 security release...

Kaese’s picture

Like I said. It's a bugfix. Doesn't answer my question, though.

WorldFallz’s picture

the best way to know what made it into a release is to check the release notes, but in this case dave updated the original issue: http://drupal.org/node/1143460#comment-7145622

so the short answer it no, it's no in the current release and still requires the dev version.

deanflory’s picture

No, not included in D7.21

adammalone’s picture

The functionality provided by this patch is now in Drupal core!

WorldFallz’s picture

Status: Active » Fixed

Yep-- I just downloaded and confirmed the module.inc file has the required changes. Finally, closing this issue!

Look for an official release of download_count within the week (I just want to install on a freshly created drupal 7.22 and confirm it works properly).

Status: Fixed » Closed (fixed)

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

gChen07’s picture

Where can we find the official new release of download count?

deanflory’s picture

The bug was in Drupal core, not this module, therefore no new module update was required. Drupal 7.22 finally fixes the problem and any patch on this issue is no longer needed as long as you're updated to Drupal 7.22.

WorldFallz’s picture

deanflory is correct. Also I anticipate the current dev version will be exactly what gets tagged as an official release, I just want to install it fresh and give it a test first-- I just haven't had the chance yet.

gChen07’s picture

I already installed the new drupal 7.22 version and the download count 7.x-3.x dev version.. download count report is available in my report link.. I downloaded a file 22 times but it does not count or reflect in my download count report.. the file is from my private folder.. I even double check my permission and uncheck the skip count for all user so even download by the administrator will be counted. Did I miss something?

gChen07’s picture

seems not ;-)