elgg deprecation


I'm trying delete a comment with ajax call with the code below:

$comment_guid = get_input('guid');
$comment = get_entity($comment_guid);

if (elgg_instanceof($comment, 'object', 'comment') && $comment->canEdit()) {
    if ($comment->delete()) {
    } else {
} else {

if (elgg_is_xhr()) {
    header("Content-Type: application/json");


 but I get this error:

Deprecated in 1.9: Use getSubtype()

This deprecation is released as they said  "only show deprecation notice if user reads ->subtype after save/load"

but I'm not after saving of loading anything. I'm just before deleting!

How do I fix this issue? 

I'm doing something wrong?

Thanks in advance.

  • I'm using elgg 1.11.0 and I get this deprecation error on deleting a blog, either (even when I'm not using an ajax call).

  • I think the deprecation warning comes from some other part of the code. You might want to check your server's logs as the deprecation warning in the log might contain more info about where exactly the problematic code is to be found.

  • @iionly the deprecation warning comes from elgg_instanceof and canEdit functions.

    But I don't know how to fix it and even what is wrong, which I get this warning!

  • If it would be a bug in Elgg core I would expect that this deprecation warning would appear a lot in the log files of any site, because elgg_instanceof() and canEdit() are used in core itself, too. But this doesn't seem the case. So, my guess is that the warnings you see are caused either by another part of your code (because the the code you've posted above there's no checking of subtype done) or the warning comes from a 3rd party plugin you use on your site.

    For testing I would suggest to first try it without any other 3rd party plugins enabled. Is there still an warning logged then? If yes, the problem is likely in another part of your code. If not, then the issue comes from one of the 3rd party plugins - and you only need to figure out from which one. Have you checked the server logs? Does it really not give more details about where the deprecated code is?

    What you would have to look for is a call like


    Instead of this it should be


  • More precisely: if it's like

    $some_entity->subtype = 'a_subtype';

    it's still okay (this sets a subtype). But on getting a subtype the getSubtype() function should be used, e.g. not

    $subtype = $some_entity->subtype;


    $subtype =  $some_entity->getSubtype();

  • I was also getting this error when deleting a blog. I found the culprit (through apache logs) inside the apiadmin plugin, line #48.

     if ( ($object) && ($object->subtype === get_subtype_id('object', 'api_key')) ) {

    I changed it to below:

    if ( ($object) && ($object->getSubtype() === get_subtype_id('object', 'api_key')) ) {

    No more error. Not sure what the linkage is between apiadmin and blogs, but the area you are getting an error in may be related to some other plugin. The steps iionly has outlined is a great way to start.