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.

Forum Module /

Discuss the Forum Module.

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

addMembershipFields error


Go to End


6 Posts   2517 Views

Avatar
iadawn

Community Member, 13 Posts

25 March 2009 at 2:54am

hi there,

I am using the nestedurls branch and Forum 0.2 rc 2 and have the following issue:

Notice: MemberTableField::addMembershipFields() is deprecated. Please implement updateSummaryFields() on a Member decorator instead. in .../cms/code/MemberTableField.php on line 70

Any thoughts on how to address this?

Thanks

Kevin

Avatar
Sean

Forum Moderator, 922 Posts

25 March 2009 at 11:33pm

Edited: 25/03/2009 11:37pm

You've got two options. Either;

1.) Remove the call to addMembershipFields() in your code completely. This will stop the notice from appearing again.

2.) Remove the call to addMembershipFields() AND create a new file called MyMemberDecorator.php (or something that makes more sense) in the mysite/code directory. Create a function called updateSummaryFields($fields) where $fields (an array of field names) is passed in by reference and you can add more/remove existing fields which directly affects the table columns in the Security section of the CMS.

More information on this can be found here: http://doc.silverstripe.com/doku.php?id=dataobjectdecorator

Sean

Avatar
iadawn

Community Member, 13 Posts

25 March 2009 at 11:42pm

Thanks for the response Sean.

This issue is actually within the Forum module. Do you know if this is likely to be associated with nestedurls branch or is this something that needs to be generally addressed?

Kevin

Avatar
iadawn

Community Member, 13 Posts

26 March 2009 at 11:08pm

Hi Sean,

Actually, I have had a look in Trac and found this ticket: http://open.silverstripe.com/ticket/3543

I would like to get this working as I could really do with both nestedurls and forums. I tried adding an updateSummaryFields into ForumRole but this didn't seem to be doing anything. Trouble is I can't seem to find out where and when updateSummaryFields is being called when I do a /dev/build.

Any thoughts or pointers would be useful,

Thanks

Kevin

Avatar
iadawn

Community Member, 13 Posts

30 March 2009 at 11:15pm

Ok, I have Forum installed and with the benefit of not having not had to do much coding.

What I did:

1. I removed the lines in forum/_config.php that called addMembershipFields

2. I added the following into forum/ForumRole.php, into the $fields array in the extraDBFields function:

'summary_fields' => array(
"Nickname" => "Nickname",
"Occupation" => "Occupation",
"Country" => "Country",
"ForumRank" => "ForumRank"
),

That covers the code changes, however, this did not get forum installed for me.

On removing the call to addMembershipFields the /dev/build progressed a little bit further but still bombed out. It was throwing and undefined index error on ForumRank at line 378 of Database.php. On looking at this I found my problem.

I had added forum into an already existing instance of SilverStripe so the Member table existed. I have not gone into this in detail but I am guessing that $this->fieldList provides a list of the current state of the table in the database. But ForumRank is not in the *current* Member table so the index was not found.

So the final steps to get this installed for me was:

3. Backup the content of the Member table

4. Drop the Member table

5. Call /dev/buil?flush=1

6. Restore the content from the backed up Member table

I am not sure if this is a bug or is working as intended. I am sure that is is irritating and I would love someone to point me in the direction of some instructions as to how to overcome this problem without the headache.

Cheers

Kevin

Avatar
iadawn

Community Member, 13 Posts

31 March 2009 at 12:15am

Not sure if this is related, but when I checked if I could edit the entries I received this message:

Fatal error: Call to a member function scaffoldFormField() on a non-object in /Users/kevin/Sites/MAPP/sapphire/forms/FormScaffolder.php on line 84

A quick check in the code lead me to buildCastingHelperCache in sapphire/core/ViewableData.php. In there a builder is created for all the fields within a class. The problem was the line:

220: $fields = eval("return {$componentClass}::\$db;");

If the data object has been extended then this will not return the full list of fields associated with the class. I changed this to:

$fields = Object::get_static( $componentClass, 'db' );

And all was well. Not sure but I think the latter is a bit cleaner?

Again, not sure how this all relates to just getting the forum working or if I have gone in completely the wrong direction. Bottom line for me is... it works.

Would love some feedback on this.

Thanks

Kevin