Hi, thanks for committing the dev version.

I get these errors when clicking a pdf to download (private file).

Warning: Missing argument 4 for download_count_file_download_access_alter(), called in /includes/module.inc on line 1003 and defined in download_count_file_download_access_alter() (line 124 of modules/download_count/download_count.module).

Notice: Undefined variable: entity in download_count_file_download_access_alter() (line 152 of modules/download_count/download_count.module).

Notice: Trying to get property of non-object in download_count_file_download_access_alter() (line 152 of 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] => 301 [:db_insert_placeholder_1] => 1 [:db_insert_placeholder_2] => node [:db_insert_placeholder_3] => [:db_insert_placeholder_4] => 127.0.0.1 [:db_insert_placeholder_5] => /s950-3u-compactpci-radiation-tolerant-powerpc%C2%AE-sbc [:db_insert_placeholder_6] => 1321544325 ) in download_count_file_download_access_alter() (line 157 of modules/download_count/download_count.module).

Comments

WorldFallz’s picture

bah... I totally forgot to mention on the project page that the d7 version requires the patch from #1143460: hook_file_download_access_alter missing entity argument. Now that the bulk of the d7 conversion is done, I'll try to push forward that patch but if anyone wants to review/take a look at it, the more eyes the better.

TripleEmcoder’s picture

Patches on that page seem to say that they are for Drupal 8, so what about the d7 version of this module? Which patch should be applied?

WorldFallz’s picture

Patches for core must always be submitted on the current dev branch and then backported which is why I had to roll the patch for d8. It might still apply to d7, but if not the changes are tiny and can be manually applied until I get a chance to roll a d7 version. Since the 2nd patch caused all sorts of test failures, I recommend using the first one.

alioso’s picture

I had it working on D7 (first version). Fixed the problem. Thanks

Anonymous’s picture

Tried patching but PDOException still exists.

Outputting $file in function download_count_file_download_access_alter seems to print file fields attributes, not actual file objects.

Edit: output of $file below

Array
(
    [translatable] => 0
    [entity_types] => Array
        (
        )

    [settings] => Array
        (
            [display_field] => 0
            [display_default] => 0
            [uri_scheme] => private
        )

    [storage] => Array
        (
            [type] => field_sql_storage
            [settings] => Array
                (
                )

            [module] => field_sql_storage
            [active] => 1
            [details] => Array
                (
                    [sql] => Array
                        (
                            [FIELD_LOAD_CURRENT] => Array
                                (
                                    [field_data_field_files] => Array
                                        (
                                            [fid] => field_files_fid
                                            [display] => field_files_display
                                            [description] => field_files_description
                                        )

                                )

                            [FIELD_LOAD_REVISION] => Array
                                (
                                    [field_revision_field_files] => Array
                                        (
                                            [fid] => field_files_fid
                                            [display] => field_files_display
                                            [description] => field_files_description
                                        )

                                )

                        )

                )

        )

    [foreign keys] => Array
        (
            [fid] => Array
                (
                    [table] => file_managed
                    [columns] => Array
                        (
                            [fid] => fid
                        )

                )

        )

    [indexes] => Array
        (
            [fid] => Array
                (
                    [0] => fid
                )

        )

    [id] => 14
    [field_name] => field_files
    [type] => file
    [module] => file
    [active] => 1
    [locked] => 0
    [cardinality] => -1
    [deleted] => 0
    [columns] => Array
        (
            [fid] => Array
                (
                    [description] => The {file_managed}.fid being referenced in this field.
                    [type] => int
                    [not null] => 
                    [unsigned] => 1
                )

            [display] => Array
                (
                    [description] => Flag to control whether this file should be displayed when viewing content.
                    [type] => int
                    [size] => tiny
                    [unsigned] => 1
                    [not null] => 1
                    [default] => 1
                )

            [description] => Array
                (
                    [description] => A description of the file.
                    [type] => text
                    [not null] => 
                )

        )

    [bundles] => Array
        (
            [node] => Array
                (
                    [0] => tyotila
                )

        )

)
WorldFallz’s picture

just an fyi-- i'm maintaining the required core patch in #1484206: use this required core patch until the core bug fix is committed.

WorldFallz’s picture

Status: Active » Fixed

which fixes this problem (people are trying to use the d8 patch for d7).

Status: Fixed » Closed (fixed)

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