I just ran Drupal's update, after installing Imagepicker 6.x-2.x-dev (release of April 23) . It gave me the White Screen. This was the error I got:
Fatal error: Call to undefined function imagepicker_user_has_role() in E:\mysite\sites\all\modules\imagepicker\contribs\imagepicker_postlet\imagepicker_postlet.module on line 407

But upon restarting my site (Drupal 6.20, on localhost), I could continue without a problem. So, I don't know if this actually means anything (apart from a second of panic).

BTW: the inclusion of the insert template (in the .example file) works like a Charm! Thanks so very very much!!

Comments

hutch’s picture

Thanks for the bug report, I will need to revisit postlet code ;-(

hutch’s picture

Status: Active » Closed (fixed)
csc4’s picture

Status: Closed (fixed) » Needs review

This is marked as fixed - but with the 2011-Dec-23 version on running update.php I'm getting

PHP Fatal error:  Call to undefined function imagepicker_user_has_role() in sites\all\modules\imagepicker\contribs\imagepicker_postlet\imagepicker_postlet.module on line 419

- is it really fixed?

I can see the function - imagepicker.functions.inc(2836): function imagepicker_user_has_role($role, $user=NULL) {

So what's different about running update which stops it being visible to imagepicker_postlet.module?

Digging some more - noticed in imagepicker_postlet_init

/**
 * Implementation of hook_init().
 */
function imagepicker_postlet_init() {
  global $user;
  if ($user->uid > 0) {
    module_load_include('inc', 'imagepicker', 'imagepicker.functions');
    module_load_include('inc', 'imagepicker', 'imagepicker.theme');
    module_load_include('inc', 'imagepicker', 'imagepicker.form-elements');
  }
}

I'm running update as user 0 - is it as simple as that condition?

hutch’s picture

Does commenting out the if condition so that the module_load_include() functions always run solve your problem?
I take it that "running update as user 0" means you are using drush...

csc4’s picture

Thanks for reply.

When I say user 0 - I mean I'm running a straight update.php as the first installed user. No Drush.

I haven't been able to run a successful update.php so I'm very puzzled I'm the only one who seems to have this problem.

In desperation to get update.php running successfully again I've tried some more digging and changing line 419 of imagepicker_postlet.module from

    if (imagepicker_user_has_role($roleid, $user) && $user->uid > 1) {
        $postlet_ok = TRUE;
    }

to

    if ($user->uid > 1) {
      if (imagepicker_user_has_role($roleid, $user)) {
        $postlet_ok = TRUE;
      }
    }

Has stopped the errors so far.

Still feel it isn't quite the right answer though - as clearly at the time imagepicker_postlet_check_ok() is being called after an update the function imagepicker_user_has_role isn't defined?

hutch’s picture

Your solution allows admin (user id 1) through as $postlet_ok default is TRUE. It still filters logged in users which is what we want without checking user 1's roles (which we don't want, user 1 should have access to everything no matter what)

function imagepicker_postlet_check_ok() {
  $postlet_ok = TRUE;
  if (variable_get('imagepicker_postlet_byrole', 0)) {
    global $user;
    if ($user->uid > 1) {
      $roleid = variable_get('imagepicker_postlet_role', 2);
      if (imagepicker_user_has_role($roleid, $user)) {
        $postlet_ok = TRUE;
      }
      else {
        $postlet_ok = FALSE;
      }
    }
  }
  return $postlet_ok;
}

I will commit this shortly.

Probably the reason I did not see this error is because I gave my user 1 the relevant role(s) in testing. I don't use it in production at all.

To be honest I haven't given postlet much attention, I am wary of tools that upload outside of Drupal's control mechanisms which is why I have not ported it to Drupal 7.

ahillio’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

I was unable to uninstall imagepicker_postlet. Drush was telling me
Error: Call to undefined function imagepicker_user_has_role() in imagepicker_postlet.module line 419.
I changed the code according to #5 (since it was shorter than #6) and was able to successfully uninstall.
Thank you.