Hypewall - Missing entity in $vars

Hello,
I'm using hypewall 6.2.0 in Elgg 3.3.12 and in "\forms\wall\status" and "\framework\wall\container", a call is made to "$entity = elgg_extract('entity', $vars);".
In both instances it returns "null". I believe the call is expecting a "Post" object (I could be wrong :)).
In "\river\object\hjwall\create" a call is made to "elgg_view('notifier/view_listener', ['entity' => $object,]);". However, this view does not exist. I'm not sure if this has any relevance.

Could someone please point me in the right direction so I can collect the expected "entity" in the container and pass it on to status.

Thanks in advance. 

  • In both instances it returns "null"

    How did you understand that?

    You can check it:

    Add

    var_dump($entity);

    After

    $entity = elgg_extract('entity', $vars);

    In both views.

  • Thanks for your response, Nikolai.

    How did you understand that?

    In an attempt to better understand Elgg, I have been using Netbeans with XDebug to remove the deprecated messages from the hypewall plugin. I've been very careful and tested after each change which mainly consisted of transferring everything out of start.php into a bootstrap class.

    I tested the original hypewall 6.2.0 and it also returned null for those two instances of 'entity'.

    The results of "var_dump($entity);" in both are:

    
    

    \mod\hypeWall\views\default\forms\wall\status.php:5:null

    
    

    mod\hypeWall\views\default\framework\wall\container.php:10:null

  • Can you reproduce your steps while I tests this plugin on my server?

    Upd: just tested it and can't find any issue with posting and editing wall posts.

  • Sorry, Nikolai, I wasn't implying there was an issue, I just wondered if the null entity was affecting functionality that I wasn't aware of. The Post object entity is present when editing a post, but not when adding a post or visiting the activity page.

    The php_error_log has two Elgg.Notice entries that appear to be related to the null entity:
    1) "Trying to get property 'guid' of non-object" in file mod\hypeWall\views\default\forms\wall\status.php
    2) "Undefined variable: entity" in file mod\hypeWall\views\default\framework\wall\container.php

    As you say, it doesn't appear to affect functionality, but I was curious as to how I could amend the script to remove the php_error_log messages.

     

  • Ah, debugging :)

    You can use this trick instead of $entity = elgg_extract('entity', $vars); :

    $class = elgg_get_entity_class('object', 'hjwall');
    
    if (!$class) {
        throw new \Elgg\BadRequestException();
    }
    
    $entity = elgg_extract('entity', $vars);
    
    if(!$entity) {
        $entity = new $class();
    }
    
    if (!$entity instanceof \ElggEntity) {
        throw new \Elgg\BadRequestException();
    }
  • Also, look at blog/save form. You can rewrite hypeWall views using same code.

  • Many thanks, Nikolai. I'll update my version of the plugin.

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking