Make WordPress Core

Opened 13 years ago

Closed 13 years ago

Last modified 11 years ago

#1614 closed defect (bug) (fixed)

Only variables can be passed by reference in classes.php

Reported by: Dehumanizer Owned by: ryan
Milestone: Priority: normal
Severity: normal Version: 1.5.2
Component: General Keywords: classes.php reference category
Focuses: Cc:


Today, I added about 40 categories to one of my blogs (http://www.dehumanizer.com/wayofthemind/), which only had 2 of them before, and went through all the posts, changing their categories from "General" to the correct ones.

Afterwards, when going to a category page (like /wayofthemind/category/xxx, assuming xxx is a category), I got this in my error logs:

[Tue Aug 23 17:43:40 2005] [error] PHP Fatal error: Only variables can be passed by reference in /var/www/htdocs/wayofthemind/wp-includes/classes.php on line 629

I looked at that file, and after a few tests, found out that changing line 629 from:

$category = &get_category($this->get('cat'));

to something like:

$crom = $this->get('cat');
$category = &get_category($crom);

makes the error disappear, and the page is correctly displayed.

When googling for info about this problem, I found about 50 other WordPress blogs displaying the same error: google for "Only variables can be passed by reference in" "classes.php on line 629"

(that's a single query), so I'm not the only one, at least..

Using WordPress 1.5.2, PHP 5.0.4, no active plugins, no local customizations except adding geotags to the RSS feeds.

A reply to my post in the support area (http://wordpress.org/support/topic/42685) suggested that:

I think this is something that has changed in PHP 5 - what used to be valid code in PHP 4 is now not valid.

$this->get('cat') is seen by PHP 5 as the result of an expression rather than a variable so can't be passed by reference.

This needs filing as a bug on trac.wordpress.org unless one already exists.

Change History (7)

#1 @ryan
13 years ago

  • Owner changed from anonymous to ryan

#4 @tlongren
13 years ago

I can verify that replacing line 629:

$category = &get_category($this->get('cat'));

with this:

$crom = $this->get('cat');
$category = &get_category($crom);

works as expected. Categories now show correctly and my apache error log isn't complaining about it anymore. This is with PHP 5.0.5 (w/ hardening-patch 0.4.3) and WordPress 1.5.2 with many plugins.

#5 @ryan
13 years ago

  • Milestone set to 1.6

Addressed in [2635].

#6 @ryan
13 years ago

  • Resolution set to fixed
  • Status changed from new to closed

#7 @(none)
11 years ago

  • Milestone 2.0 deleted

Milestone 2.0 deleted

Note: See TracTickets for help on using tickets.