When new users try to register, they get:

Fatal error: __clone method called on non-object in /path_to_drupal/includes/common.inc on line 1497

This apparently started happening after we upgraded to php 5.2.9. The MySQL is 5.0.77.
Updating Drupal from 5.1 to 5.16 didn't fix it. The Web server is Apache, the Unix is Redhat, all up to date.

You can see the error happening if you try to register at http://www.kuphitau.com/

Comments

jmcneely’s picture

drat, this issue still exists after the upgrade to Drupal 5.18. The only difference is that the error message is:
Fatal error: __clone method called on non-object in /
/includes/common.inc on line 1506

celston’s picture

In core, there are only calls to drupal_clone in modules/node/node.module and modules/taxonomy/taxonomy.module. Most calls in node.module are wrapped in an is_object check. The only others deal with node_preview and theme_node_preview which I doubt new users are hitting. That only leaves taxonomy.module, specifically taxonomy_get_tree, line 1012.

  if ($children[$vid][$parent]) {
    foreach ($children[$vid][$parent] as $child) {
      if ($max_depth > $depth) {
        $term = drupal_clone($terms[$vid][$child]);
        $term->depth = $depth;
        // The "parent" attribute is not useful, as it would show one parent only.
        unset($term->parent);
        $term->parents = $parents[$vid][$child];
        $tree[] = $term;

        if ($children[$vid][$child]) {
          $tree = array_merge($tree, taxonomy_get_tree($vid, $child, $depth, $max_depth));
        }
      }
    }
  }

Should there be a check that $terms[$vid][$child] is defined and an object?

damien tournoud’s picture

Category: bug » support
Status: Active » Postponed (maintainer needs more info)

Could you give us more information about this error? For example, try to add the following debug code at the beginning of drupal_clone():

if (!is_object($object)) {
  print_r(debug_backtrace());
}

And report the results.

jmcneely’s picture

Status: Active » Postponed (maintainer needs more info)

We did come up with a workaround that allowed new users to register again. It is weird because the problem appears to be in a version check for PHP4, and we are using PHP5.

In /includes/common.inc:
# line1506

/**
 * Provide a substitute clone() function for PHP4.
 */
function drupal_clone($object) {
  return version_compare(phpversion(), '5.0') < 0 ? $object : clone($object);
}

When we comment out this 'function' the gallery2 module fails to load.

Fatal error: Call to undefined function drupal_clone() in /path_to_drupal/sites/all/modules/gallery/gallery.module on line 70

--
But when we just commented out the single line of the phpversion check, it worked :)

/**
 * Provide a substitute clone() function for PHP4.
 */
function drupal_clone($object) {
  # return version_compare(phpversion(), '5.0') < 0 ? $object : clone($object);
}

So the 'function' is still there, and commenting out the version check for php4 doesn't seem to break anything.

P.S.: Except that it did break the taxonomy module's ability to display the lists of terms in vocabularies. It doesn't display any error message, it just displays a blank list of terms, with no Names, for all the vocabularies. The entries for each term are still present, but the Names are blank. Even the entries for the Forums vocabulary are blank, and, alas, the Forums disappeared. When I uncommented that line, the Forums came back, but new-user registration is more important than the forums ...

jmcneely’s picture

Status: Postponed (maintainer needs more info) » Active

Thank you very much for the reply!

That debug code reports back:

Array ( [0] => Array ( [file] => /path_to_drupal/includes/bootstrap.inc [line] => 961 [function] => require_once ) [1] => Array ( [file] => /path_to_drupal/includes/bootstrap.inc [line] => 902 [function] => _drupal_bootstrap [args] => Array ( [0] => 7 ) ) [2] => Array ( [file] => /path_to_drupal/index.php [line] => 13 [function] => drupal_bootstrap [args] => Array ( [0] => 7 ) ) )

asimmonds’s picture

Status: Postponed (maintainer needs more info) » Active

That backtrace looks like the debug code from #3 was placed outside a function, instead of something like:

/**
* Provide a substitute clone() function for PHP4.
*/
function drupal_clone($object) {
  if (!is_object($object)) {
    print_r(debug_backtrace());
  }
  return version_compare(phpversion(), '5.0') < 0 ? $object : clone($object);
}
dpearcefl’s picture

Status: Active » Closed (won't fix)

Considering the lack of activity on this issue and that Drupal v5 is no longer supported by fixes or patches, I am going to close this ticket. If this issue still exists and you want to continue to ask for technical support, please reopen and update this ticket.