Hi - there was a forum topic started on this issue: node/407018 - thought I would submit as an issue.

My post:
Hi - same problem here, single server single site. I can upload files (they are now defaulting to the "Default" database repository - how do I change it back to using the "Default (File System)" btw?) and attach them to nodes, but when trying to access the content I receive a 403 forbidden message. This occurs whether downloading / accessing from the node, or when trying to directly download using "bitcache/guid...."

I can go directly to admin/content/bitcache and see all of my uploaded guids... they appear to be present in the database...

Seems there is some new code in the overloaded 'allow' function of the Bitstream Server class. I removed the check for allowable bitstream features and downloads seem to be back now.

In the bitcache module (sites/all/modules/bitcache) in the 'bitcache.server.inc' file, find the line (around 106) and comment out the if statement like I did below (add the // to the beginning of the line).

//if (($method != 'HEAD' && empty($methods[strtolower($method)])) || ($method == 'HEAD' && empty($methods['get']))) {
    //return FALSE;
//}

I'm not sure if this will have an impact on security? The check was not there in the last revision of bitcache so I'm not sure... Might be wise to check with the folks who develop bitcache and are more familiar with how it works...

Comments

thekevinday’s picture

I found out that this is caused by the update from beta1 to beta2.

Go to: admin/settings/bitcache

Then disable Bitcache REST API.
Now, enable Bitcache REST API.

Apparently some of the internal data doesn't get fully flushed on update.

This was tested and confirmed on a control-server I was using to test the ACL issues I was working on.

The specified hack is not necessary.

v8powerage’s picture

I didn't updated anything, just installed fresh this module and it never worked, rest api is disabled all the time

phow’s picture

Ah - yes - thank you - confirmed this fixes the problem for me...

jwalkerbg’s picture

This

Then disable Bitcache REST API.
Now, enable Bitcache REST API.

works for me.

v8powerage’s picture

This
Then disable Bitcache REST API.
Now, enable Bitcache REST API.
works for me.

This solution doesn't works for me :(

bensnyder’s picture

worked for me on a FRESH install

v8powerage’s picture

I installed all of the newest versions for the first time on two different servers, and I'm not able even upload any single file, I'm getting only errors at /node/add/file:



    * warning: array_diff_key() [function.array-diff-key]: Argument #1 is not an array in /modules/bitcache/bitcache.module on line 677.
    * warning: array_merge() [function.array-merge]: Argument #1 is not an array in /modules/bitcache/bitcache.module on line 677.
    * warning: array_merge() [function.array-merge]: Argument #2 is not an array in /modules/bitcache/bitcache.module on line 677.
    * recoverable fatal error: Argument 1 passed to Bitcache_FileRepository::__construct() must be an array, null given, called in modules/bitcache/bitcache.module on line 681 and defined in modules/bitcache/adapters/file.inc on line 13.
    * warning: array_merge() [function.array-merge]: Argument #2 is not an array in /modules/bitcache/adapters/file.inc on line 21.
    * The directory does not exist.
    * warning: copy() [function.copy]: open_basedir restriction in effect. File(/c9c68310b6a33ca416cf781cf3fba3838c828b15) is not within the allowed path(s): (/var/www/virtual/mysite/:/usr/share/php/) in /modules/bitcache/adapters/file.inc on line 163.
    * warning: copy(/c9c68310b6a33ca416cf781cf3fba3838c828b15) [function.copy]: failed to open stream: Operation not permitted in /modules/bitcache/adapters/file.inc on line 163.
    * Error saving file mod.jpg. Please, contact site administrator.
    * A file upload must be provided.
rellis’s picture

StatusFileSize
new2.28 KB

Looks like the problem is on line 102 of bitcache.admin.inc...
The default argument to variable_get() should be an array with
'index', 'get', etc. as keys.

?

rellis’s picture

StatusFileSize
new964 bytes

Sorry, that patch is wrong. Trying again...

miglius’s picture

Status: Active » Fixed
Issue tags: +upgrade

This bug is already addressed in the HEAD version. If you're using beta2, please follow the release notes at http://drupal.org/node/405738:

You must run update.php after upgrading to this release. In addition, you should also re-save the module's configuration (at admin/settings/bitcache).

v8powerage’s picture

rellis I added Your patch, but it didn't help a bit, it's still exactly the same situation, the same errors appears on node/add/file

thekevinday’s picture

Have you checked for a filesystem permissions issue?

If it's not filesystem permissions, is selinux enabled or some sort of apache/php security module/patch?
These may be causing some problem as well.

v8powerage’s picture

There is safe_mode and open base dir on all servers at which I was testing this.

thekevinday’s picture

well, that explains this error:
open_basedir restriction in effect.

This was in the middle of that output you presented here: http://drupal.org/comment/reply/408504#comment-1399182
Looks like open_basedir may be conflicting with bitcache.

A quick google search reveals the following link:
http://wiki.archlinux.org/index.php/PostFix_Howto
Close to the bottom is this "troubleshooting" quote:

If you received an error similar to

Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(/var/lib/squirrelmail/data) is not within the allowed path(s): (/srv/http/:/home/:/tmp/:/usr/share/pear/) in /home/httpd/site.virtual/virtualdomain.tld/html/squirrelmail/src/configtest.php on line 303

. Edit /etc/httpd/httpd.conf and in the section

add

php_admin_value open_basedir /home/httpd/site.virtual/virtualdomain.tld/html:/var/lib/squirrelmail/

So, here I would suggest substituting the squirrelmail stuff with the drupal bitcache.

At this point I would conclude this to not be a bitcache problem but instead be an open_basedir configuration problem.

v8powerage’s picture

I think it's not open basedir fault, but bitcache, because bitcache wants save file in / instead in my home directory.

redraco’s picture

Yes. You have right. I've the same problem but now all is working (meybe not exactly all). I think problem was because in table bitcache_repositories in column named "options" I've got only %s in all rows (some time ago I've errors after update bitcache).
I think You must install newest RDF module (alpha7) and bitcache, then try pass bitcache update 6004 (this update schould copy configuration from variable table for bitcache to table bitcache_repositories).
After all column "options" from table bitcache_repositories schould looks like:

"a:2:{s:5:"title";s:9:"Domyślny";s:11:"description";s:0:"";}"
"a:3:{s:5:"title";s:21:"Default (file system)";s:11:"description";s:0:"";s:8:"location";s:26:"/mainpath/files/bitcache";}"
"a:7:{s:5:"title";s:14:"File framework";s:11:"description";s:50:"A repository for the file framework managed files.";s:11:"fingerprint";s:4:"sha1";s:6:"encode";s:6:"base16";s:8:"compress";s:0:"";s:7:"encrypt";s:0:"";s:8:"location";s:31:"/mainpath/files/bitcache/file";}"

Sorry for my english :)
Maybe this can help.

v8powerage’s picture

I done what You've said, but during running upda.php I got these errors:

user warning: Duplicate entry 'bitcache' for key 1 query: INSERT INTO bitcache_repositories VALUES ('bitcache', 'bitcache', 'sql', 1, 1, 0, -10, 'a:2:{s:5:\"title\";s:7:\"Default\";s:11:\"description\";s:0:\"\";}') in /var/www/virtual/shaman.us.to/test/htdocs/modules/bitcache/bitcache.install on line 274.

Updates were attempted. If you see no failures below, you may proceed happily to the administration pages. Otherwise, you may need to update your database manually. All errors have been logged.

* Main page
* Administration pages

The following queries were executed
rdf module
Update #6002

    * CREATE TABLE {rdf_repositories} ( `name` VARCHAR(64) NOT NULL, `module` VARCHAR(255) NOT NULL, `type` VARCHAR(16) NOT NULL, `enabled` TINYINT NOT NULL DEFAULT 0, `mutable` TINYINT NOT NULL DEFAULT 0, `weight` SMALLINT NOT NULL DEFAULT 0, `options` LONGTEXT DEFAULT NULL, PRIMARY KEY (name) ) /*!40100 DEFAULT CHARACTER SET UTF8 */

Update #6003

    * INSERT INTO {rdf_repositories} (name, module, type, enabled, mutable, weight, options) VALUES ('file', 'rdf', 'local', 1, 1, 0, '%s')
    * DELETE FROM {variable} WHERE name = 'rdf_db_repository[file]'
    * INSERT INTO {rdf_repositories} (name, module, type, enabled, mutable, weight, options) VALUES ('local', 'rdf', 'local', 1, 1, 0, '%s')
    * DELETE FROM {variable} WHERE name = 'rdf_db_repository[local]'

bitcache module
Update #6004

    * Failed: INSERT INTO {bitcache_repositories} VALUES ('bitcache', 'bitcache', 'sql', 1, 1, 0, -10, '%s')
    * INSERT INTO {bitcache_repositories} VALUES ('default', '', 'file', 1, 1, 0, -1, '%s')

And it still doesn't works

v8powerage’s picture

I tested this on server without openbasedir restriction but I'm still not able to make this working and I'm getting following errors:

* warning: array_diff_key() [function.array-diff-key]: Argument #1 is not an array in /home/unitra2/htdocs/modules/bitcache/bitcache.module on line 677.
* warning: array_merge() [function.array-merge]: Argument #1 is not an array in /home/unitra2/htdocs/modules/bitcache/bitcache.module on line 677.
* warning: array_merge() [function.array-merge]: Argument #2 is not an array in /home/unitra2/htdocs/modules/bitcache/bitcache.module on line 677.
* recoverable fatal error: Argument 1 passed to Bitcache_FileRepository::__construct() must be an array, null given, called in /home/unitra2/htdocs/modules/bitcache/bitcache.module on line 681 and defined in /home/unitra2/htdocs/modules/bitcache/adapters/file.inc on line 13.
* warning: array_merge() [function.array-merge]: Argument #2 is not an array in /home/unitra2/htdocs/modules/bitcache/adapters/file.inc on line 21.
* The directory does not exist.
* warning: copy(/444bafe76d89a8231c48d6f8e250c9d4895eda06) [function.copy]: failed to open stream: Permission denied in /home/unitra2/htdocs/modules/bitcache/adapters/file.inc on line 163.
* Error saving file 3002.jpg. Please, contact site administrator.
* A file upload must be provided.

Nobody's keen to help? I don't know how to make this working, this is frustrating :/

kmonty’s picture

I'm getting the same errors as #18 -Shaman- above.

kmonty’s picture

Update to #19. I realized I forgot to install ARC2, but I'm still getting errors (albeit less than before)

This is when I am attempting to upload a file with the fileframework module:

warning: array_diff_key() [function.array-diff-key]: Argument #1 is not an array in /var/www/CUT/httpdocs/sites/all/modules/bitcache/bitcache.module on line 692.
warning: array_merge() [function.array-merge]: Argument #1 is not an array in /var/www/CUT/httpdocs/sites/all/modules/bitcache/bitcache.module on line 692.
warning: array_merge() [function.array-merge]: Argument #2 is not an array in /var/www/CUT/httpdocs/sites/all/modules/bitcache/bitcache.module on line 692.
warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'stdClass::put_file' was given in /var/www/CUT/httpdocs/sites/all/modules/bitcache/bitcache.module on line 819.
Error saving file FILENAME.pdf. Please, contact site administrator.

kmonty’s picture

v8powerage’s picture

Status: Fixed » Active

It's not fixed for me, once I upload file I'm getting this error:

* user warning: Column 'fid' cannot be null query: INSERT INTO files (fid, uid, filename, filepath, filemime, filesize, status, timestamp) VALUES (NULL, 3, 'drupal_bitcache_t60ybE', '/tmp/drupal_bitcache_t60ybE', 'application/octet-stream', 0, 0, 1239832402) in /home/unitra2/htdocs/modules/bitcache/bitcache.module on line 858.

And I'm still not able to see/download any kind of file, I'm getting 403 errors.

thekevinday’s picture

This looks like a bitcache specific problem.

For whatever reason, bitcache seems to be trying to place a temporary file into the original drupal file database.
Which is apparently different from the fileframework file database.

Looking at the drupal code, this is how the "files" table gets installed:

  $schema['files'] = array(
    'description' => 'Stores information for uploaded files.',
    'fields' => array(
      'fid' => array(
        'description' => 'Primary Key: Unique files ID.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE),

.. etc ..

Notice that it is in fact defined as NOT NULL, but also as type SERIAL.

Drupal seems to have a history with using non-portable SQL code in their projects.
I suspect that with whatever database the programmer who wrote that line of code was using would assume that if a NULL is supplied, then the next available number in the SERIAL would be used.

apparently, the SQL database you are using does not assume that.

To fix this problem, I was looking up at the MySQL and PostgreSQL documentation.

PostgreSQL directly states that by not supplying a value during the insert for an auto-increment, the auto-increment will then be performed.
MySQL does not directly state this, but a number of provided examples suggests this.

Therefore the fix is to remove fid entirely from the INSERT statement.
(will this break any other database that might be used??)

I supplied a patch that does this.
Please confirm that it does work as I have no way of reproducing your case and testing it myself.

However, this problem brings to question:
1) why is bitcache directly inserting into the file database instead of using a callback
2) what must fileframework do to take control of this particular function?

v8powerage’s picture

@thekevinday - I applied Your patch, error previously quoted by me dissapeared, but it still doesn't works.

If You're committed to help me (and others) resolve this, I'll give You access to my testing page, just send me pm please.

kmonty’s picture

Status: Active » Needs review
v8powerage’s picture

Someone perhaps made this working with this patch, I've been trying but unsuccesfully :/

v8powerage’s picture

StatusFileSize
new53.19 KB

This is error which I'm geting each time when try upload a file.

v8powerage’s picture

StatusFileSize
new26.8 KB

Sorry, for two posts above, but can't delete replies (btw, this takes me to other issue #10700: Ability to delete own comments before reply is added)

Someone perhaps made this working with this patch? I've been trying but unsuccesfully :/

I'm attaching picture of error which I'm getting each time when try upload file.

v8powerage’s picture

Status: Needs review » Active

Here's my issue on this error (mine always getting closed after 1 day) http://drupal.org/node/403960

manuel.adan’s picture

Hi,

Same problem here. As far I can see, a repository with id 'file' is expected, so renaming (or creating) a repository with such id solves, in part, the issue, because a new one come along:

'Error saving file myfile.jpg. Please, contact site administrator.'

last entry in log:

'The RDF data was not deleted for the subject s=.'

Any ideas?

Thank's

v8powerage’s picture

I have repository 'file' but it's not helping a bit, still nothing works :-(

highermath’s picture

It sounds like there are several different issues here. I solved my 403 error by using the solution in the first comment.

There are also file permissions issues that should be addressed as a separate issue.

v8powerage’s picture

That would be too easy to be true ;-) Issues I'm experiencing are faar more complexed, I installed this thing on 4 servers and I was getting same results everywhere… I suggested maintainer to take a look into my website but he didn't responded to me. Now I simply uninstalled this and searching some other module, which would have this functionality: http://drupal.org/node/503986

JerryH’s picture

adan

Did you ever find out what the fix was ?

I have the exact same bug here.

manuel.adan’s picture

I didn't Jerry, finally I discarded the use of this module for my project.

info2madhu’s picture

It works with the latest dev snapshot

v8powerage’s picture

this module should be renamed bitheadache, it's almost impossible to get it working, once I made it files were unaccessible (403), now there's full of errors on upload and file doesn't even get uploaded (I pasted them somewhere here)…

tomhung’s picture

Go to: admin/settings/bitcache

Then disable Bitcache REST API.
Now, enable Bitcache REST API.

worked for me.

zabec’s picture

Enabling and disabling Bitcache REST API worked for me too.

Anonymous’s picture

I'VE THE SAME PROBLEM.
DO YOU KNOW THE SOLUTION FOR THIS? THANKS

chefarov’s picture

This:

Go to: admin/settings/bitcache

Then disable Bitcache REST API.
Now, enable Bitcache REST API.

Worked for me too, thanks !

Just now when I try to view : docs, odts and pdfs it tries to download them. I suppose that's not featured in module(=not a bug) ?

johanneshahn’s picture

Status: Active » Closed (cannot reproduce)

No activity