Notice: Undefined property: stdClass::$introeditor in /Applications/MAMP/htdocs/moodle/course/modlib.php on line 593

Notice: Undefined property: stdClass::$introeditor in /Applications/MAMP/htdocs/moodle/course/modlib.php on line 593

by Stefano Pettorossi -
Number of replies: 8

Hi everybody,

i'm developing an activity module plug-in for moodle, and i can't understand why i get this error when I create/update an instance of the plugin in a course:

Notice: Undefined property: stdClass::$introeditor in [...path...]/moodle/course/modlib.php on line 593

I've already added the these fields in DB structure for the instance:

<FIELD NAME="intro" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" />
<FIELD NAME="introformat" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" />
<FIELD NAME="introeditor" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" />
This fixed the problem for intro and introformat, but the introeditor error keeps popping up

Thanks in advance

Greetings

Average of ratings: -
In reply to Stefano Pettorossi

Re: Notice: Undefined property: stdClass::$introeditor in /Applications/MAMP/htdocs/moodle/course/modlib.php on line 593

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
You shouldn't have a DB field called 'introeditor' - the field is called 'intro', 'introeditor' is the name of the editor element on the form.

Do you have a call to $this->standard_intro_elements(); in your plugin's mod_form.php? In lib.php, does your PLUGINNAME_supports() function return true for FEATURE_MOD_INTRO?
Average of ratings: Useful (1)
In reply to Davo Smith

Ri: Re: Notice: Undefined property: stdClass::$introeditor in /Applications/MAMP/htdocs/moodle/course/modlib.php on line 593

by Stefano Pettorossi -
Hi, thanks for the reply.

Could you explain to me what this intro is? Why do I have to have this field in the table in DB?

Anyway
No, I don't have a call to $this->standard_intro_elements(); in my mod_form.php and no PLUGINNAME_supports() function in my lib.php.
Should they be added? What are they for?

Is there any documentation about this "intro" field and these functions that I need to create?

Thanks in advance
In reply to Stefano Pettorossi

Re: Ri: Re: Notice: Undefined property: stdClass::$introeditor in /Applications/MAMP/htdocs/moodle/course/modlib.php on line 593

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
The intro is the standard 'description' field that appears for most activities (e.g. when creating a new forum activity, it is the second field below "Forum name") - I believe it is optional; it is only required if your PLUGINNAME_supports() function returns true for FEATURE_MOD_INTRO.

Just to be really clear, the function is not literally called PLUGINNAME_supports() - you haven't shared the name of your plugin, so I can't answer directly, but in mod_forum the function is called, forum_supports(), mod_page has page_supports(), etc.

If you are creating your first plugin, it is highly recommended that you use https://moodle.org/plugins/tool_pluginskel to create all the basic files that you need. There is also a Moodle Plugin Development Basics course that should cover all the details of how to create a plugin at - https://learn.moodle.org/ (I haven't taken the course, as I'd already been writing Moodle code for 12 years before the course was created, but I hear good things about it).
Average of ratings: Useful (1)
In reply to Davo Smith

Ri: Re: Ri: Re: Notice: Undefined property: stdClass::$introeditor in /Applications/MAMP/htdocs/moodle/course/modlib.php on line 593

by Stefano Pettorossi -
Thanks a lot Davo, for all the information.

It's weird, because as I wrote, I don't have the "synapses_supports()" function (synapses is the plugin name), I just have synapses_[add | edit | delete]_instance()

And I don't use $this->standard_intro_elements(); in mod_form.php

However, that annoying message keeps appearing to me (Notice: Undefined property: stdClass::$introeditor)


Anyway
I solved it by adding this in the lib:
function synapses_supports() { return false; }


I don't know about the PLUGINNAME_supports() function, so I kindly ask you if you think it is a good solution or if it can cause problems of some kind.

Thanks again Davo!
In reply to Stefano Pettorossi

Re: Ri: Re: Ri: Re: Notice: Undefined property: stdClass::$introeditor in /Applications/MAMP/htdocs/moodle/course/modlib.php on line 593

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
All activity plugins should implement the _supports() function, as it allows you to declare which bits of optional functionality you support (for example, the intro/description field, groups, completion, grades, backup). If you don't use (and never plan to use) any of that functionality, then I guess it would probably work without it, but it would be more maintainable to implement it properly (see any of the core activity plugins for examples of how to implement it - it is very simple).
Average of ratings: Useful (1)
In reply to Davo Smith

Ri: Re: Ri: Re: Ri: Re: Notice: Undefined property: stdClass::$introeditor in /Applications/MAMP/htdocs/moodle/course/modlib.php on line 593

by Stefano Pettorossi -
Found it
Awesome, thank you very much Davo!
Greetings
In reply to Davo Smith

Re: Notice: Undefined property: stdClass::$introeditor in /Applications/MAMP/htdocs/moodle/course/modlib.php on line 593

by Frederik Evans -
The field intro is compulsory, it is required and should always be used. Non usage of this mandatory field will always result in an error message undefined stdClass::$introeditor appearing 

Notice: Undefined property: stdClass::$intro in C:\Apache24\htdocs\moodle\lib\weblib.php on line 1594

There is currently no fix to this known bug.
In reply to Frederik Evans

Re: Notice: Undefined property: stdClass::$introeditor in /Applications/MAMP/htdocs/moodle/course/modlib.php on line 593

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Frederik,

If this is a known bug, could you include a link to the Moodle tracker ticket where this bug is reported?

It looks like it should be easy to fix, by adding a quick check to the format_module_intro(), something like:

if (!plugin_supports('mod', $module, FEATURE_MOD_INTRO)) {
return '';
}