WordPress.org

Ready to get started?Download WordPress

Forums

User Access Manager
[resolved] Error on PHP 5.4.0 (8 posts)

  1. Marcus Downing
    Member
    Posted 1 year ago #

    PHP 5.4.0 removed the call-time pass-by-reference feature, so trying to use this plugin results in the error:

    Fatal error: Call-time pass-by-reference has been removed in /home/mdowning/Projects/data/itso/htdocs/wp-content/plugins/user-access-manager/class/UamUserGroup.class.php on line 646

    This is due to the following code:

    $this->objects[$objectType][$type]
      = $plObject['reference']->($plObject['getFullObjects']}(
        $this->objects[$objectType][$type],
        &$this
      );

    http://wordpress.org/extend/plugins/user-access-manager/

  2. AndrewJHart
    Member
    Posted 1 year ago #

    this is true but it should be a simple fix; I do not use this plugin however PHP now defaults to passing by reference, so theres nothing wrong with the way the function is defined but there is a problem with the way it is called now!

    New versions of PHP no longer require a pass by reference to implicitly require the & before the variable when passed as a param.

    the simple fix: Edit the line near 646 that passes the 'this' object by reference. Change &$this to just $this (php knows its passed by reference because the function should declare it).

    You will also need to edit line 995 and do the same thing.

    this was done in new version of php for code cleanliness - basically the function declaration decides how the variable is passed, not the caller.

    Drew

  3. swartlkk
    Member
    Posted 1 year ago #

    I have edited the reference & have gotten past the fatal error and now the plugin can activate, however there are even more problems with this plugin. Once this error was corrected, my site now renders correctly when logged in. However, when not logged in, I get warnings on the main page.

    Warning: Creating default object from empty value in .../wp-content/plugins/user-access-manager/class/UamAccessHandler.class.php on line 678

    Line 678 is part of this function call:

    /**
         * Return the role of the user.
         *
         * @param integer $userId The user id.
         *
         * @return string|null
         */
        private function _getUserRole($userId)
        {
            global $wpdb;
    
            $curUserdata = get_userdata($userId);
    
            if (!isset($curUserdata->user_level)) {
                $curUserdata->user_level = null;
            }
    
            if (isset($curUserdata->{$wpdb->prefix . "capabilities"})) {
                $capabilities = $curUserdata->{$wpdb->prefix . "capabilities"};
            } else {
                $capabilities = null;
            }
    
            $role  = (is_array($capabilities) && count($capabilities) > 0) ? array_keys($capabilities) : array('norole');
    
            return trim($role[0]);
        }

    Specifically the "$curUserdata->user_level = null;" line.

    Your help is greatly appreciated!

    I have disabled all error reporting which has returned my home page to it's former state & everything seems to be working as it should, but I would like to know how to fix this appropriately.

  4. akiko.pusu
    Member
    Posted 1 year ago #

    Hello.
    Thanks for this information, I could activate this plugin.
    But I still have the same worning, such as

    Warning: Creating default object from empty value in .../wp-content/plugins/user-access-manager/class/UamAccessHandler.class.php on line 678

    So I did change the line 678 and warning was stopped.
    I'm not sure if this workaround is correct or not...

    if (!empty($curUserdata->user_level) && !isset($curUserdata->user_level)) {
    /* if (!isset($curUserdata->user_level)) { */
    $curUserdata->user_level = null;
    }

  5. Hemang
    Member
    Posted 1 year ago #

    Trying to use this plugin results in the error:

    Fatal error: Call-time pass-by-reference has been removed in /home/mdowning/Projects/data/itso/htdocs/wp-content/plugins/user-access-manager/class/UamUserGroup.class.php on line 646

    I tried to remove the '&' from line 646 and 995, but then it shows error as Plugin activation shows a Fatal error and no error description. I have updated my xampp for linux to xampp version 1.8.1 which has php version 5.4.7. Can you tell me if any other change is required?

  6. jloosli
    Member
    Posted 1 year ago #

    I was receiving the same error, but I after changing:

    &$this

    to

    $this

    on lines 645 and 994, it worked

  7. axeldev
    Member
    Posted 1 year ago #

    Hello,

    I made the changes posted by jloosli in UamUserGroup.class.php and it worked for me too.

  8. GM_Alex
    Member
    Plugin Author

    Posted 1 year ago #

    Fixed since version 1.2.3

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.