Hi Maintainer,

Im testing beta_3 on a 5.3 installation and found some problems.

1. If I install private_upload i got a lot of erroes becaue opendir, closedir, is wrong.
2. I created the folder private by myself in the files dir. I Created the .htaccess ok.

my actual status:
* Public File Folder: 'files'
* Private File Folder: 'files/private'
*
files/private is writable. Great.
*
Not able to test the security of your private directory (files/private). Either the directory is empty or you are using PHP4.
*
You have an .htaccess file in private folder. Great.
*
File download method is set to public. Great.
*
There are no old-style private files hanging around. Great.
*
There are '0' files in the private folder, and the DB thinks there are '0' private files. Great.
* There are no public files attached to private nodes. Great.
* Uploaded files in db: '19' files attached to '9' nodes.

But if I upload a file and check the private checkbox, the file is stored in the normal file dir not in the files/private folder.

So do what I have to do?

Dirk

Comments

starbow’s picture

Status: Active » Postponed (maintainer needs more info)

what do you mean:

1. If I install private_upload i got a lot of erroes becaue opendir, closedir, is wrong?

designwork’s picture

Hi strabow,

after installing i got the warning (if I remember right), that opendir and closedir are not known commands...

But I can test it again!!!

My main problem is that even if i flag a file as private its not stored in the dir files/private but in the normal files dir.

Dirk

starbow’s picture

If your system doesn't know about opendir:
http://us.php.net/manual/en/function.opendir.php
and closedir:
http://us.php.net/manual/en/function.closedir.php
it's kind of surprising that any of the file handling code works at all.

designwork’s picture

Hi starbow,

ok i deleted everything and strated again. Going to admin/settings/private_upload i got hte following message:

* warning: opendir(files/private) [function.opendir]: failed to open dir: No such file or directory in /kunden/163565_20459/webseiten/dirksway/modules/private_upload/private_upload.module on line 118.
* warning: readdir(): supplied argument is not a valid Directory resource in /kunden/163565_20459/webseiten/dirksway/modules/private_upload/private_upload.module on line 119.
* warning: closedir(): supplied argument is not a valid Directory resource in /kunden/163565_20459/webseiten/dirksway/modules/private_upload/private_upload.module on line 125.
* warning: opendir(files/private) [function.opendir]: failed to open dir: No such file or directory in /kunden/163565_20459/webseiten/dirksway/modules/private_upload/private_upload.module on line 416.
* warning: readdir(): supplied argument is not a valid Directory resource in /kunden/163565_20459/webseiten/dirksway/modules/private_upload/private_upload.module on line 417.
* warning: closedir(): supplied argument is not a valid Directory resource in /kunden/163565_20459/webseiten/dirksway/modules/private_upload/private_upload.module on line 422.

Ok i made my folder private in the dir. files.

Now I have the following status:
* Public File Folder: 'files'
* Private File Folder: 'files/private'
* files/private is writable. Great.
* Not able to test the security of your private directory (files/private). Either the directory is empty or you are using PHP4.
* You have an .htaccess file in private folder. Great.
* File download method is set to public. Great.
* There are no old-style private files hanging around. Great.
* There are '0' files in the private folder, and the DB thinks there are '0' private files. Great.
* There are no public files attached to private nodes. Great.
* Uploaded files in db: '19' files attached to '9' nodes.

I created a new article uploaded a file witch is set to private. I saved the article. But the attached file is now in the folder files not in the folder files/private.

What did I wrong?

Dirk

starbow’s picture

Have you checked your admin/logs/status page? I suspect there is something up with your 'files' directory.

designwork’s picture

Hi starbow,

yes i checked it look at my status:
Drupal 5.5
Cron-Wartungsaufgaben Zuletzt vor 1 Minute 47 Sekunden ausgeführt
Cron kann per Hand ausgeführt werden.
Dateisystem Beschreibbar (öffentliche Download-Methode) >> public
Datenbankschema Aktuell
Konfigurationsdatei Geschützt
MySQL-Datenbank 5.0.45
PHP 5.2.4
Private Upload Security of private directory is unknown.
Not able to test the security of your private directory (files/private). Either the directory is empty or you are using PHP4.
Unicode-Bibliothek PHP mbstring-Erweiterung
Webserver Apache/1.3 (Unix) mod_ssl/2.8.28 OpenSSL/0.9.8f AuthPG/1.3 FrontPage/5.0.2.2635

I´m not shure what could be wrong?

Dirk

starbow’s picture

Can you give beta4 a try? It has some improved status testing methods that might give me more information.

designwork’s picture

Hi Strabow,

it tested beta3 again today on a clean install of 5.5 and got the same problems. I will have a look at the code today.
Ps i will only work with verison beta4 OK

Dirk

designwork’s picture

Version: 5.x-1.0-beta3 » 5.x-1.0-beta4

Hi Strabow,

I tried everything with beta4 and now i got the following warning after attaching a file to a node "Private Upload: Private checkbox not in form.". The file is still stored in the main files dir. not in files/private.

My Status is:
* Public File Folder: 'files'
* Private File Folder: 'files/private'
* files/private exists and is writable. Great.
* You have an .htaccess file in private folder. Great.
* Your private folder is not accessable. Great!
* File download method is set to public. Great.
* There are no old-style private files hanging around. Great.
* There are '0' files in the private folder, and the DB thinks there are '0' private files. Great.
* There are no public files attached to private nodes. Great.
* Uploaded files in db: '1' files attached to '1' nodes.

I´m running the same MySQL and PHP config like above.
So whats going on?

Dirk

iokevins’s picture

Hi,

On submit or preview of a form, I also receive the "Private Upload: Private checkbox not in form." error. I'm running a relatively new install of 5.5 with beta4.

Function private_upload_form_validate() reports this error. I suspect function private_upload_form_alter() is not injecting the private checkbox properly--I'm learning about how the forms API works as I go here, so perhaps I can offer a fix if I stumble across the solution. I'm finding

          echo "<pre>";
          print_R($form);
          echo "</pre>";

quite useful in seeing the structure of the form for debugging purposes.

Peace

designwork’s picture

Hi strawbow,

now I have one more error when I go to /admin I get the following error message: "warning: Missing argument 2 for private_upload_requirements() in /kunden/163565_20459/webseiten/freelens_2/modules/private_upload/private_upload.module on line 88."

I will check it tomorrow.

Dirk

starbow’s picture

@DesignWork & schultkl: My current working theory is that if you see the "Private Upload: Private checkbox not in form." error, then there is another module that is in conflict with Private Upload. Please try disabling all your non-core modules and see if that fixes the problem for you.

Also, ignore the warning in #11. That will be gone in the next beta.

iokevins’s picture

Hi Starbow,

Unchecking everything in admin/build/modules (except upload and Private Upload) failed to remove the error. I'm still investigating and I'll let you know what I find.

Peace

iokevins’s picture

Hi Starbow,

Since both modules have module weight zero, module upload overrides this private_upload::private_upload_form_alter() assignment, as modules evaluate in alphabetical order:

    303   $form['attachments']['wrapper']['files']['#theme'] = 'private_upload_form';

By the time includes/form.inc::drupal_prepare_form() finishes this code:

    363   foreach (module_implements('form_alter') as $module) {
    364     $function = $module .'_form_alter';
    365     $function($form_id, $form);
    366   }

the value set by module private_upload above is "upload_form_current".

Solution: Setting the weight of the upload module to a value less than private_upload (for example, -1) fixes this issue.

private_upload_form_validate() now displays "Hi Tao" at the top of the screen as a successful validation should.

Peace

iokevins’s picture

StatusFileSize
new639 bytes

Per:

Howto: Update a module's weight
http://drupal.org/node/110238

I've created a file implementing hook private_upload_install() for updating table system when the module is installed. Alternatively, you might incoporate it into private_upload.module.

<?php

/**
 * Implementation of hook_install().
 *
 * Ensures private_upload runs after module upload
 */
function private_upload_install() {

  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $weight = (int)db_result(db_query("SELECT weight FROM {system} WHERE name = 'upload'"));
      db_query("UPDATE {system} SET weight = %d WHERE name = 'private_upload'", $weight+1);
      break;

    case 'pgsql':
      $weight = (int)db_result(db_query("SELECT weight FROM {system} WHERE name = 'upload'"));
      db_query("UPDATE {system} SET weight = %d WHERE name = 'private_upload'", $weight+1);
      break;
  }
}

Peace

iokevins’s picture

Status: Postponed (maintainer needs more info) » Needs review
starbow’s picture

Status: Needs review » Postponed (maintainer needs more info)

@DesignWork: Ok, I have committed a variation on schultkl's patch to beta5. Please give that a try (be sure to visit the status page to trigger the weight change). I am a little dubious, but if this fixes it, great.

designwork’s picture

Status: Postponed (maintainer needs more info) » Needs review

Hi All,

I tested the beta4 with the new install and I have the same problems. Nothing changed!!! Just to correct I have a clean install 5.5 with no contrib modules exept private_upload.

Describing the stuff. Creating a node and attching a file shows first the core upload theme function only after attaching a file I see the private_upload theme function with the private checkbox. Saving the node brings me back to the core theme function. If I edit the node again under files attachments I see the core function again the private checkbox is not there!

should be the hook_form_alter.

Lets start here.....

Dirk

starbow’s picture

Version: 5.x-1.0-beta4 » 5.x-1.0-beta5
Status: Needs review » Postponed (maintainer needs more info)
StatusFileSize
new2.6 KB

Please try this with beta5. Let's see if it is a module weight problem.

Actually, if you can, please apply this patch - it should have better error messages. If you can't apply this patch, be sure to visit /admin/settings/private_upload before retesting.

Thanks.

iokevins’s picture

Hi Starbow,

At 12:07 PST, I'm unable to download beta5:

Not Found

The requested URL /files/projects/private_upload-5.x-1.0-beta5.tar.gz was not found on this server.

Also, a minor change suggestion--bug 202235 in the release notes:

http://drupal.org/node/202235: schultkl's Fix for migrating private files if same file attached to multiple nodes.

fixed the case when multiple roles have access to a node with a file attachment.

Peace

iokevins’s picture

Hi Starbow,

I tested this patch and it seems to resolve the problem. After visiting admin/settings/private_upload I see the message:

Setting private_upload.module weight to 1

When I visit the private node, I immediately see the private checkbox in the File Attachments area.

BTW--the second chunk of the patch looks strange to me:

@@ -429,15 +436,7 @@

   // get status messages from the requirements hook.
   _private_upload_requirements('runtime', $status);
-
-  // Be sure to go after core upload.module (weight=0).
-  $upload_weight = (int)db_result(db_query("SELECT weight FROM {system} WHERE name = 'upload'"));
-  $private_weight = (int)db_result(db_query("SELECT weight FROM {system} WHERE name = 'private_upload'"));
-  if ($private_weight <= $upload_weight) {
-    drupal_set_message( "Setting private_upload.module weight to ". ($upload_weight+1));
-    db_query("UPDATE {system} SET weight = '%d' WHERE name = 'private_upload'", $upload_weight+1);
-  }
-
+
   // loop through all the file in private folder & collect stats.
   $private_file_count = 0;
   $d = opendir( $private_path );

It seems backwards--it seems to me the patch should add (+) the core upload.module check. I'm relatively new to patching so perhaps I'm confused in this instance.

Peace

iokevins’s picture

@DesignWork

You're describing the same problem I had.

If you're willing and able, please find table system in your database. Look at the weights for records "private_upload" and "upload" (last column). Record private_upload should have a weight that's greater than record upload. If not, please change record private_upload to have a greater weight than record upload. Finally, revisit the node with the error.

Please let me know if that fixes the problem.

It seems you may have tested with beta4, which does not correct the problem. Beta5 doesn't seem to be available just yet but should correct the issue.

Peace

Kevin

starbow’s picture

Assigned: designwork » starbow

Weird that beta5 isn't showing up. I rolled in the patch and did another released as beta6, but it's not showing up yet either. Hmm, I bet the packaging system is just running slow today. If you are chomping at the bit, you can pull a copy of the most recent code from: http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/private_upl...
(Update: the beta packages just showed up).

@schultkl: You are right about the math being wrong in #21. In a patch, any line that starts with '-' is being removed, and any line that starts with '+' is being added. So the lines with the bad math are being removed by the patch.

iokevins’s picture

Hi Starbow, DesignWork,

I just installed a new instance of Drupal 5.5 and module private_upload beta6, and everything works as expected.

Hoping this resolves your issue.

Peace

designwork’s picture

Hi schultkl,

yes i installed the beta6 version and it worked. Look at my system table and private_upload has weigth1 upload has weight 0. But on a clean install i still got the opendir. error message like above if the folder private is not in the files dir.. So I will change that.

Dirk

iokevins’s picture

That's wonderful news Dirk. Wishing you continued success.

Kevin

starbow’s picture

Status: Postponed (maintainer needs more info) » Fixed

great

Anonymous’s picture

Status: Fixed » Closed (fixed)

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