Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

DataObjectSet::append() is deprecated ?


Go to End


4 Posts   2953 Views

Avatar
OzziNL

Community Member, 37 Posts

7 August 2008 at 12:43am

Hi,
I get this notice after upgrading to 2.2.2 : DataObjectSet::append() is deprecated. Use DataObjectSet::merge() instead.

But DataObjectSet::merge() is not 'compatible' with append. In the append method it is possible to append a DataObject to a DataObjectSet. With merge this is not possible.

So when I have a DataObjectSet, how can I append one DataObect to it?

$returnSet = new DataObjectSet();
$pages = DataObject::get("SiteTree","ParentID = " . $this->ID,"","");
		if (!$pages) return null;
		foreach ($pages as $p) {
			
			if ($p->ClassName == 'VirtualPage') // VP 
			{
				$np = DataObject::get_by_id('VirtualPage', $p->ID);
				$newp = DataObject::get_by_id("SiteTree", $np->CopyContentFromID);
				$returnSet->append($newp);
// cut // cut // cut

Avatar
OzziNL

Community Member, 37 Posts

29 September 2008 at 7:54pm

//just a kick for some attention ;)

Avatar
FlorianH

Community Member, 33 Posts

30 September 2008 at 2:12am

Use DataObjectSet::push() instead.

Avatar
Willr

Forum Moderator, 5523 Posts

30 September 2008 at 5:42pm

Im pretty sure you can just call push() which should add it to the end, just like FlorianH has said

$returnSet->push($newp);