Recent Topics

1 Jan 26, 2008 07:45    

My b2evolution Version: 1.10.x

I recently moved to a new ISP and have transfered files from the old to new. After some configuration, everything seems to be fine except for the side-bar on one of my blogs. I'm getting an error message which reads:

Notice: Only variables should be assigned by reference in /blogs/skins/custom02/_linkblog.php on line 60

I'm not sure what this notice is about or how to rid of it.

Thanks,[/quote]

2 Jan 26, 2008 09:03

Hi absent,

Welcome to the forums.
It looks as if your new host has the phperror messages set up different. This is no problem, but now it reveals an error. Since yu seem to be using an adapted skin I cannot tell from here what exactly the error is. It says there is an & in a php line where it shouldn't be. Something like:

$r = & true;


It's on line 60 in the file that is mentioned. If you find it, delete and try again. If you can't solve this problem, please post the line in this topic and we will have a closer look.

Good luck

3 Jan 26, 2008 19:46

Here's the code form the offending linkblog.php file:

<?php
/**
 * This is the template that displays the linkblog
 *
 * This file is not meant to be called directly.
 * It is meant to be called by an include in the _main.php template.
 *
 * b2evolution - {@link http://b2evolution.net/}
 * Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
 * @copyright (c)2003-2006 by Francois PLANQUE - {@link http://fplanque.net/}
 *
 * @package evoskins
 * @subpackage wpc
 */
if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );

if( !isset( $linkblog ) )
{	// No link blog explicitely specified, we use default:
	$linkblog = $Blog->get('links_blog_ID');
}

if( ! $linkblog )
{	// No linkblog blog requested for this blog
	return;
}

# maximum number of linkblog entries to display:
if(!isset($linkblog_limit)) $linkblog_limit = 20;
# global linkblog delimiters:
if(!isset($linkblog_main_start)) $linkblog_main_start = '';
if(!isset($linkblog_main_end)) $linkblog_main_end = '';
# Category delimiters:
if(!isset($linkblog_catname_before)) $linkblog_catname_before = '<li>';
if(!isset($linkblog_catname_after)) $linkblog_catname_after = '<ul>';
if(!isset($linkblog_catlist_end)) $linkblog_catlist_end = '</ul></li>';
# Item delimiters:
if(!isset($linkblog_item_before)) $linkblog_item_before = '<li>';
if(!isset($linkblog_item_after)) $linkblog_item_after = '</li>';


// --- //


// Load the linkblog blog:
$LinkblogList = & new ItemList( $linkblog, array(), '', '', '', $linkblog_cat, $linkblog_catsel, '', 'ASC',
																'main_cat_ID title', $linkblog_limit, '', '', '', '', '', '', '',
																'posts', $timestamp_min, $timestamp_max );


// Dirty trick until we get everything into objects:
$saved_blog = $blog;
$blog = $linkblog;

// Open the global list
echo $linkblog_main_start;

$previous_cat = '';
$linkblog_cat = '';

while( $Item = & $LinkblogList->get_category_group() )
{
	// Open new cat:
	echo $linkblog_catname_before;
	$Item->main_category();
	echo $linkblog_catname_after;

	while( $Item = & $LinkblogList->get_item() )
	{
		echo $linkblog_item_before;
		$Item->title();
		echo ' ';
		$Item->content( 1, 0, T_('more'), '[', ']' );	// Description + more link
		echo $linkblog_item_after;
	}

	// Close cat
	echo $linkblog_catlist_end;
}
// Close the global list
echo $linkblog_main_end;

// Restore after dirty trick:
$blog = $saved_blog;
?>


In my editor, line 60 is I believe line 45. This does have the "&" symbol, but deleting it does not rid the error (notice:) message on the page. Any other thoughts?
By the way, what's the significance of the "&" symbol in .php?

4 Jan 26, 2008 20:13

while( $Item = & $LinkblogList->get_category_group() )


The & sign is for reference variables.
Take this:

$a = 6;
$b = $a;


Now two variables exist with only the value in common. If I now do:

$a = 4;


Then $a = 4 and $b = (still) 6
Now if I reference the variables:

$a = 6;
$b = & $a;


I have two variables pointing to one memory location. So if I do:

$a = 4


*or*

$b = 4;


then $a = 4 *and* $b = 4.

The relevance of this is in large datastructures, like objects, classes. If one is made every time the variable is called, it may get busy in memory. So calling by reference only makes one instance and saves resources.

5 Jan 26, 2008 22:47

So variables Item and $LinkblogList are pointed to the same data. I'm not seeing a problem there.

Given my limited knowledge of .php scripting (little to none), I think I'll replace the linkblog file altogether and delete all my back office linkblog posts and see what happens.

I don't know how long this error's been going on, as like you said, the new server handles the problem differently.

I'll let you know the results.

6 Jan 26, 2008 23:36

In the saga of ampersand and string, it looks like it worked. Things are a little different, but hey - trouble's fixed.

I notice the old file did not have the pesky "&" before $LinkblogList, so that seems to have been the problem. It does undermine some of my faith in cyberspace, since I don't understand how it got there. I sure didn't add it.

Thanks for your time and help>

(Note: Item should read $Item)


Form is loading...