Hello!
I am using Ubercart 6.x-2.0-rc6 on Drupal 6.13 and have a problem with the uc_file module.
The Systems works generally, I can sell products with associated downloads and the buyers can download the files. My problem is the "File downloads" (Files) - menu in "My account":
- Downloads and Addresses are not saved. Every time I go back to this page or reload it after I made a download, "Downloads" is still 0/3 (my setting is max. 3 downloads) and "Addresses" still 1/2 (my setting is max 2 Addresses). These numbers do not get higher and I (admin) and buyers can download their files as many times as they want.
- A even bigger problem: I go to the "File downloads" - menu in "My account", download a file, reload the "File downloads" - page and get the following error messages:
warning: in_array() [function.in-array]: Wrong datatype for second argument in /home/[deleted]/[deleted]/sites/all/modules/ubercart/uc_file/uc_file.pages.inc on line 190.
warning: in_array() [function.in-array]: Wrong datatype for second argument in /home/[deleted]/[deleted]/sites/all/modules/ubercart/uc_file/uc_file.pages.inc on line 334.
I think the problem is "!in_array($ip, $addresses)" in these lines. If the array $addresses is/stays empty, it would explain the error message above and would be the reason why the number of downloads or addresses are not stored.
Is this a general bug or a problem because of my system / other installed modules?
Other information that might be interesting in this case:
Server Linux Debian, Apache 2, MySQL 5.0.X, PHP 5.2X
Ubercart Payment Gateway: Test Gateway (Credit Card)
Installed non-core Ubercart Modules: VAT (uc_vat), Legal aspects checkout pane
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | 561692_downloads_page.patch | 2.63 KB | Island Usurper |
Comments
Comment #1
tisbris commentedHi
I do also see this error...
download is ok, downloadcount change - but when you change screen error occur and the downloadcount is reset.
I only use ulimited adresses and only see one error:
warning: in_array() [function.in-array]: Wrong datatype for second argument in /home/www/onleje4.jobbud.dk/modules/ubercart/uc_file/uc_file.pages.inc on line 334.
//Brian
Comment #2
zx2964 commentedI just received a complaint from a customer because of this error. It is the same problem as described above: Addresses and Downloads are not stored, Calling the page several times brings up the error message >>warning: in_array() [function.in-array]: Wrong datatype for second argument<<
Comment #3
murokoma commentedSame Problem here:
warning: in_array() [function.in-array]: Wrong datatype for second argument in /sites/all/modules/ubercart/uc_file/uc_file.pages.inc on line 190.
warning: in_array() [function.in-array]: Wrong datatype for second argument in /sites/all/modules/ubercart/uc_file/uc_file.pages.inc on line 334.
Comment #4
bobba commentedI also have the same problem.
Is someone here able to fix that error (or at least hide it)?
For a download shop, this is a very critical problem.
Comment #5
univate commentedin_array is expecting an array variable as its second argument, that error just means that the $address variable is not an array.
The problem is probably in the unserialize call which really shouldn't occur in these function, it should be moved to where the file data is retrieved from the db.
Comment #6
Vlad-1981 commentedI tested my ebook-shop and it shows these error messages plus the download limits are not working either.
Because I wanted to open my shop to the public this week, this is a very big problem for me.
So how to solve this problem? I am not exactly an expert in programming and the official team of ubercart does not seem to be interested in this problem. At least there is no official statement since this problem was brought up nearly two weeks ago.
Perhaps we should collect some money to let a professional programmer look over it?
Comment #7
bobba commentedAny news regarding the error mentioned above?
Is uc_file still actively maintained, or is it time to search for another download-shop-solution that is working correctly?
Comment #8
rszrama commentedStill maintained.
Comment #9
Island Usurper commentedArgh. I had made a post before lunch, but someone cleared out all of the sessions on drupal.org again, so it didn't get saved.
Anyhow, I think I've taken care of all of the problems mentioned in this thread. At one point, the addresses were changed to be unserialized when they were loaded from the database, but there seems to have been a spot or two where that didn't get changed.
Comment #10
Island Usurper commentedComment #11
Lapurd09 commentedIsland Usurper,
first of all, thanks for trying to help! I patched my files and the following happened:
- Patch showed no error
- I ran update.php in the modules section after the patch, again no error
- Selling & downloading files is working normally
- The mentioned error-messages are gone
And now to the bad things ...
(again I go the "File downloads" - menu in "My account", download a file and reload the page after the download is finished)
- Instead the following error message is shown:
warning: mysqli_real_escape_string() expects parameter 2 to be string, array given in /home/[deleted]/[deleted]/includes/database.mysqli.inc- And the downloads and addresses are still not counted (0, 0)
Comment #12
Island Usurper commentedI don't see that problem. Can you figure out a way to see which line of code causes that error?
Comment #13
Lapurd09 commentedSorry that my answer might not be very helpful, but I am a user, not a developer.
1) The complete error message says: "warning: mysqli_real_escape_string() expects parameter 2 to be string, array given in /home/-/-/includes/database.mysqli.inc on line 323."
2) This error message only shows when the ip or the download number of a user has to be written to the database. Otherwise everything works ok.
3) This error happens for new users as well as for registered users
4) The database "uc_file_users" has the following data stored for all users:
"accessed" : "0"
"addresses" : "a:0:{}"
"download_limit" : "3"
"address_limit" : "2"
5) Same error when setting download limit and address limit to unlimited
6) My shop is not connected to the public internet at the moment, so no test possible by others.
For me it looks like the data "accesses" and "addresses" can now be read (beforehand it that was not possible and the result were the in_array() errors). But information still can not be written to the database. So the error must be somewhere in the write functions of the download / address limit - checks.
Let's wait and see if someone else has the same problem. If not, than it must be a problem with one of the other modules I use (uc_vat, the tax_line_alter.patch for uc_vat, Legal aspects checkout pane)
Comment #14
Lapurd09 commentedUpdate:
I tested your patch on a fresh installation of drupal 6 and ubercart, and now everything works correctly.
It seems there was a bug in my old drupal/ubercart-system. So forget comments #11 and #13 ;)
Thanks again!
Comment #15
Island Usurper commentedOK, glad you figured it out. Since the patch works, it's committed. Thanks.
Comment #16
j0rd commentedSame issue. Glad there's a patch.
Thanks again
JOrdans