Getting an error

Fatal error: Call to undefined function: user_access() in /big/dom/{username}/www/drupal/includes/common.inc on line 1921

Any help would be appreciated.

Comments

heine’s picture

See http://drupal.org/node/26256

Perhaps you could tell us a little more?
--
Tips for posting to the forums

jeremycameron’s picture

What further information are you looking for? This is a fresh install on a hosted website in which we are attempting to use Drupal as our CMS. I followed the installation instructions provided by Drupal and attempted to access the site and got the error above. I'm a little fuzzy on the resolution in the thread you linked in your reply or if there even was a resolution.

heine’s picture

As much info as you have available.
From Tips for posting to the forums

Detailed specifics. Often, before someone may be able to assist you, they will need to know the Drupal version number, the hosting environment, the specific error generated, and other information. Vague support requests just end up requiring a volley of question and answer, lengthening the time it takes to resolve an issue.

The cause of the problem for one poster was the deletion of all modules in the modules directory. Since you have a fresh install this isn't it I guess.

Another cause of the fatal error discussed in the thread I linked to is an incompatablity with Zend Optimizer or IONCube (both PHP optimizers). These optimizers cause erratic behaviour of foreach loops (returning arrays instead of single array elements). This depends on the php and optimizer version.

To see if such optimizers are enabled, paste the following into a file e.g. 'info.php' and upload it to your server. Then use your favorite browser to go to http://example.com/info.php

info.php:

<?php
phpinfo();
?>

The key phrases from the thread I linked to:

The site works again. Although I haven't got a reply from the hosting company yet, with phpinfo() I saw that IONCube is no longer enabled. Zend v1.3.0 is still enabled.

So perhaps IONCube was the problem!

I resolved a user_access error by disabling ZendOptimizer.

--
Tips for posting to the forums

jeremycameron’s picture

Here is the info you requested:

OS: Linux
Apache v1.3.33
Zend Optimizer v2.5.7
php v4.3.10
latest ver of drupal

heine’s picture

Apparantly user.module is not loaded.

Check that all files are properly uploaded (user.module should be in modules), and that Apache has read access to the modules directory. Also check in the database that the status column of the "system" database table for user.module is set to 1.

To see if it's a foreach() optimizer problem (phpaccellerator, zend optimiser, ioncube) you can use the following code in afile.php (or disable all optimizers)

<?php
$a = array (1, 2, 3, 17);

foreach ($a as $v) {
   print "Value of \$a: $v.\n";
}
?>

Load http://example.com/afile.php. When foreach() works properly this should print

Value of $a: 1.
Value of $a: 2.
Value of $a: 3.
Value of $a: 17.

--Some background--

Common.inc calls user_access after calling module_init()

module_init();

if (!user_access('bypass input data check')) {

module_init is located in module.inc and calls module_load_all:

function module_init() {
  module_load_all();
  module_invoke_all('init');
}


function module_load_all() {
  $list = module_list(TRUE, FALSE);
  $status = TRUE;

  foreach ($list as $module) {
    $status = (drupal_load('module', $module) && $status);
  }
  return $status;
}

See for even more background http://drupal.org/node/10858

--
Tips for posting to the forums

jeremycameron’s picture

* The user.module is uploaded and in the correct directory.
* Apache has rw access to the dir.
* The foreach() function works properly.
* All values in system table are set to '1'

We are still getting the same error. Any further help would be appreciated.

heine’s picture

[..] Apache has read access to the modules directory.

Sorry, what I meant to say is that the Apache user needs to be able to read the module. Make sure this user has the execute permission on all directories.

--
Tips for posting to the forums

jeremycameron’s picture

The Apache user has full permissions on all directories in the Drupal instance.

Do you have any other ideas as to what may cause this issue?

Matthew Doucette’s picture

I am having similar problems, and your afile.php example FAILS for me. Here is the output of your afile.php example:

Value of $a: Array. Value of $a: Array. Value of $a: Array. Value of $a: Array.

Just to be sure, I will go copy and paste the source code of afile.php:

<?php
$a = array (1, 2, 3, 17);
foreach ($a as $v) {
   print "Value of \$a: $v.\n";
}
?>

So, does this mean I should disable Zend?

Here is my info:

Server API  Apache  
Virtual Directory Support  disabled  
PHP API  20020918  
PHP Extension  20020429  
Zend Extension  20021010  
Debug Build  no  
Thread Safety  disabled  
Registered PHP Streams  

__________
Matthew Doucette / Xona.com

heine’s picture

Yes, though no garantue it will solve your problem, it's the best bet.

To disable Zend, locate your php.ini file, open it and comment all zend_ variables with a semi-colon.

Example

[ZEND]
;zend_optimizer.optimization_level=15
;zend_extension_manager.optimizer=/usr/local/Zend/lib/Optimizer-2_6_0
;zend_extension_manager.optimizer_ts=/usr/local/Zend/lib/Optimizer_TS-2_6_0
;zend_optimizer.version=2.6.0
;zend_extension=/usr/local/Zend/lib/ZendExtensionManager.so
;zend_extension_ts=/usr/local/Zend/lib/ZendExtensionManager_TS.so

Restart Apache after the edit.

Good luck!
--
Tips for posting to the forums.
When your problem is solved, please post a follow-up to the thread you started.

Matthew Doucette’s picture

Thanks, but no luck for me. I do not have access to the php.ini file! I was hoping for another method of disabling it, as I do not have access to server configuration files.

__________
Matthew Doucette / Xona.com

heine’s picture

If you do not control the server, contact your host and explain your problem.

Symptom: Drupal fails with a fatal error, because an essential module is not included.

Immediate cause: PHP statement foreach returns arrays instead of array items.

Diagnosis: Most likely a problem / incompatability between PHP and a PHP accelerator (eg Zend optimizer).

--
Tips for posting to the forums.
When your problem is solved, please post a follow-up to the thread you started.

Matthew Doucette’s picture

Is installing Zend Optimizer a difficult thing to do? It seems quite easy based on these instructions:

http://www.zend.com/content/download/490/1981/file/ZendOptimizer_UserGui...

Just wondering how big a deal it would be to do it myself... with my inexperience that is... Everything's always easy right until things go wrong and you don't have the experience to bail yourself out! :)

Anyways, it looks extremely automated.

__________
Matthew Doucette / Xona.com

heine’s picture

Installing is not very difficult, but I doubt you have sufficient rights on the server to do so.
--
Tips for posting to the forums.
When your problem is solved, please post a follow-up to the thread you started.

Matthew Doucette’s picture

Zend Extension 20021010 does seem quite old. Assuming Drupal DOES work with ZendOptimizer, I should get my host to upgrade.

Is Drupal known to have problems with older versions of ZendOptimizer?

__________
Matthew Doucette / Xona.com

heine’s picture

When basic PHP language constructs such as foreach() do not work properly I think it's safe to say it's a problem with PHP & Zend Optimizer, not with Drupal.

--
Tips for posting to the forums.
When your problem is solved, please post a follow-up to the thread you started.

Matthew Doucette’s picture

Exactly. I agree. I did not mean to blame Drupal... I was just questioning whether it is know to work with ZendOptimizer's older versions. ZendOptimizer is obviously flawed and the cause of at least one problem on my server.
__________
Matthew Doucette / Xona.com

heine’s picture

Drupal works on php + zend optimizer, but only when those two are compatible. Your host probably upgraded php, but forgot to upgrade the optimizer as well (happened twice on one of my hosts).
--
Tips for posting to the forums.
When your problem is solved, please post a follow-up to the thread you started.