Commit c825410f authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Fix fatal error on delete wallpost page

Trying to access blocktype/wall/deletepost.php with a bad wallpost id
creates a new empty View object, and attempts to commit it to the db
when the View destructor is called.  This fails with an sql error, and
then a PHP Fatal error.

Change-Id: I7e462cc4ea6cda0611e432336839d153bbd0a42e
Signed-off-by: default avatarRichard Mansfield <>
parent 0043cc83
......@@ -34,17 +34,21 @@ safe_require('blocktype', 'wall');
$postid = param_integer('postid');
$return = param_variable('return');
$wallpost = get_record('blocktype_wall_post', 'id', $postid);
$instance = new BlockInstance($wallpost->instance);
$view = new View($instance->get('view'));
if (!PluginBlocktypeWall::can_delete_wallpost($wallpost->from, $view->get('owner'))) {
if (!$wallpost = get_record('blocktype_wall_post', 'id', $postid)) {
throw new NotFoundException();
if (!$instance = new BlockInstance($wallpost->instance)) {
throw new NotFoundException();
$owner = $instance->get_view()->get('owner');
if (!PluginBlocktypeWall::can_delete_wallpost($wallpost->from, $owner)) {
throw new AccessDeniedException();
$goto = get_config('wwwroot');
$goto .= ($return == 'wall')
? '/blocktype/wall/wall.php?id=' . $instance->get('id')
: '/user/view.php?id=' . $view->get('owner');
: '/user/view.php?id=' . $owner;
$form = pieform(array(
'name' => 'deletepost',
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment