View Issue Details

This bug affects 1 person(s).
 10
IDProjectCategoryView StatusLast Update
11727Bug reportsExpression Managerpublic2016-10-21 10:41
ReporterTonyM Assigned Toollehar  
PrioritynoneSeveritypartial_block 
Status closedResolutionfixed 
Product Version2.52.x 
Fixed in Version2.54 
Summary11727: "Undefined index: LEMsid" with a plugin sidebody URL
Description

I got this error after logging in and entering a survey: "Undefined index: LEMsid" at application/helpers/expressions/em_manager_helper.php(4803)

The method call at
https://github.com/LimeSurvey/LimeSurvey/blob/4bfbbba7613306f470c97b578ff86023d98c4226/application/core/Survey_Common_Action.php#L260
does not match the method signature:
static function StartProcessingPage($allOnOnePage=false,$initializeVars=false)

Steps To Reproduce
TagsNo tags attached.
Attached Files
TestPlugin.php (286 bytes)   
<?php

class TestPlugin extends ls\pluginmanager\PluginBase {

  protected $storage = 'DbStorage';
  static protected $name = 'TestPlugin';
  static protected $description = 'test';

  protected $settings = array();

  function handleAdminRequest( $surveyId ) {

    echo 'test';
  }
}
TestPlugin.php (286 bytes)   
TestPlugin2.php (416 bytes)   
<?php

class TestPlugin2 extends ls\pluginmanager\PluginBase {

  protected $storage = 'DbStorage';
  static protected $name = 'TestPlugin2';
  static protected $description = 'test';

  protected $settings = array();

  function handleAdminRequest( $surveyId ) {

    return '<strong>Some content wrapped inside the Limesurvey admin dashboard HTML wrapper. Survey ID is '. ( (int) $surveyId ) .'.</strong>';
  }
}

TestPlugin2.php (416 bytes)   
ExamplePlugin.php (1,388 bytes)
Bug heat10
Complete LimeSurvey version number (& build)2.52+160920
I will donate to the project if issue is resolvedNo
Browser
Database type & versionMySQL Ver 15.1 Distrib 10.0.27-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
Server OS (if known)Debian
Webserver software & version (if known)Apache
PHP VersionPHP 5.4.45

Users monitoring this issue

DenisChenu

Activities

ollehar

ollehar

2016-10-14 16:50

administrator   ~41361

Not sure what you're trying to do here. The documentation is not entirely up to date with regard to plugins and 2.5.

You can check this plugin for examples: https://github.com/olleharstedt/MassAction/blob/master/MassAction.php#L933

Feel free to ask any questions.

Olle

TonyM

TonyM

2016-10-15 12:18

reporter   ~41370

I need a reliable way to create custom admin pages, that are wrapped inside the Limesurvey admin UI, in two flavors:

  • Custom admin page with only the generic admin UI (no survey-specific UI)
  • Custom admin page wrapped inside the survey-specific UI

See the attached screenshots.

P.S. I noticed that the TestPlugin.php is slightly wrong (echo instead of return). I attached the corrected TestPlugin2.php (browse to http://example.com/limesurvey/admin/pluginhelper?sa=sidebody&amp;plugin=TestPlugin2&amp;method=handleAdminRequest&amp;surveyId=&lt;id_of_an_existing_survey>).

P.P.S. I never got newDirectRequest to work. The attached plugin NewDirectRequestNotWorking.php illustrates the problem (see also issue 10645), so I used the plugin sidebody URLs instead.

NewDirectRequestNotWorking.php (1,116 bytes)   
<?php

/**
 * When accessing the path:
 *
 *  http://localhost/limesurvey/plugins/direct/?plugin=NewDirectRequestNotWorking&function=someEndpoint
 *
 * this plugin throws the error:
 *
 *  Alias "ext.Menu.MenuWidget" is invalid. Make sure it points to an existing PHP file and the file is readable.
 *  /framework/YiiBase.php(323)
 */
class NewDirectRequestNotWorking extends ls\pluginmanager\PluginBase {

  protected $storage = 'DbStorage';
  static protected $name = 'NewDirectRequestNotWorking';
  static protected $description = 'test';

  protected $settings = array();

  function init() {

    $this->subscribe( 'newDirectRequest' );
  }

  function newDirectRequest() {

    $event = $this->event;

    if ( $event->get( 'target' ) === __CLASS__ ) {
      $functionToCall = $event->get( 'function' );
      if ( method_exists( $this, $functionToCall ) ) {
        $content = $this->$functionToCall();
        $event->setContent( $this, $content );
      }
    }
  }

  function someEndpoint() {

    return '<strong>Some content wrapped inside the Limesurvey admin dashboard HTML wrapper.</strong>';
  }
}

NewDirectRequestNotWorking.php (1,116 bytes)   
TonyM

TonyM

2016-10-15 12:26

reporter   ~41371

The URL in Screenshot_2016-10-15_12-22-26.png (when surveyId is non-zero) only works, when I change the Survey_Common_Action.php call from

LimeExpressionManager::StartProcessingPage(false, Yii::app()->baseUrl)

to

LimeExpressionManager::StartProcessingPage(false).

Here are again the steps to reproduce:

DenisChenu

DenisChenu

2016-10-15 13:08

developer   ~41372

PS : newDirectRequest don't have any helper. More for json, dieredirect in fact.

M%aybe add a new function in it for 'quickduplay message/content) to public : https://bugs.limesurvey.org/view.php?id=11801

Minimal layout for public survey.

I lik ethe idea to have different event for public part VS admin part.

ollehar

ollehar

2016-10-17 10:50

administrator   ~41384

Last edited: 2016-10-17 10:50

Tony, your URL is wrong, I'm afraid. 2.5 uses a plugin helper, like this:

localhost/index.php/admin/pluginhelper?sa=sidebody&plugin=ExamplePlugin&method=actionIndex&surveyId=793951

ollehar

ollehar

2016-10-17 11:03

administrator   ~41385

Check this example plugin. BUT: You will have to pull the latest update from github, the necessary code is not released yet (will be soon).

ollehar

ollehar

2016-10-17 11:03

administrator   ~41386

A question: Which manual page did you first stumble upon when trying to implement plugin? If you give me a link I can update it.

ollehar

ollehar

2016-10-17 11:05

administrator   ~41387

Note that pluginhelper has two subactions (sa) you will use: "sidebody" and "fullpagewrapper". The "sidebody" subaction needs surveyId as a param:

    $href = Yii::app()->createUrl(
        'admin/pluginhelper',
        array(
            'sa' => 'sidebody',
            'plugin' => 'CintLink',
            'method' => 'actionIndex',
            'surveyId' => $surveyId
        )
    );

For "fullpagewrapper":

    $href = $this->api->createUrl(
        'admin/pluginhelper',
        array(
            'sa' => 'fullpagewrapper',
            'plugin' => $this->getName(),
            'method' => 'actionIndexGlobal'
        )
    );

Hope this helps!

Olle

TonyM

TonyM

2016-10-18 21:30

reporter   ~41450

Which part of my URL is incorrect? My URL
http://example.com/limesurvey/admin/pluginhelper?sa=sidebody&amp;plugin=TestPlugin2&amp;method=handleAdminRequest&amp;surveyId=&lt;id_of_an_existing_survey>
looks similar to your suggested URL
localhost/index.php/admin/pluginhelper?sa=sidebody&plugin=ExamplePlugin&method=actionIndex&surveyId=793951

The "fullpagewrapper" is a nice addition. It will be useful for me, so that I don't have to fake a full-page-wrapped custom admin page anymore with the "sidebody" subaction and no surveyId.

I checked the ExamplePlugin.php. Why is it using the newDirectRequest event? If I delete the newDirectRequest() and the init() methods from this plugin, the sidebody and fullpagewrapper URLs still work.

The bug mentioned in the ticket description still exists in 2.54.4. Have you tried to reproduce the steps?

Using a subdirectory installation of Limesurvey, this fails:

This succeeds:

TonyM

TonyM

2016-10-18 21:38

reporter   ~41451

(I can't seem to be able to edit the message, but the last URL should of course have the surveyId 1235.)

DenisChenu

DenisChenu

2016-10-18 23:46

developer   ~41453

Great reproduction : LEMsid is related to expression manager start. But try reproducing issue with example plugin :

Go to the link just after login : no issue for me

BUT : seems more a core bug here : maybe LEM session is not set just before adding a survey. Not really needed in fact ....

ollehar

ollehar

2016-10-19 10:16

administrator   ~41460

OK, I can confirm that bug. Will have a look.

ollehar

ollehar

2016-10-19 11:33

administrator   ~41480

Fix committed to master branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&amp;id=21100

c_schmitz

c_schmitz

2016-10-21 10:41

administrator   ~41517

Version 2.55 released

Related Changesets

LimeSurvey: master 6a432f99

2016-10-19 10:32:22

ollehar

Details Diff
Fixed issue 11727: 'Undefined index: LEMsid' with a plugin sidebody URL Affected Issues
11727
mod - application/core/Survey_Common_Action.php Diff File

Issue History

Date Modified Username Field Change
2016-09-29 13:31 TonyM New Issue
2016-09-29 13:31 TonyM File Added: TestPlugin.php
2016-09-30 00:23 DenisChenu Issue Monitored: DenisChenu
2016-10-14 16:50 ollehar Note Added: 41361
2016-10-14 16:50 ollehar Assigned To => ollehar
2016-10-14 16:50 ollehar Status new => assigned
2016-10-15 11:49 TonyM File Added: Screenshot_2016-10-15_12-22-38.png
2016-10-15 11:50 TonyM File Added: Screenshot_2016-10-15_12-22-26.png
2016-10-15 11:52 TonyM File Added: TestPlugin2.php
2016-10-15 12:18 TonyM File Added: NewDirectRequestNotWorking.php
2016-10-15 12:18 TonyM Note Added: 41370
2016-10-15 12:26 TonyM Note Added: 41371
2016-10-15 13:08 DenisChenu Note Added: 41372
2016-10-17 10:50 ollehar Note Added: 41384
2016-10-17 10:50 ollehar Note Edited: 41384
2016-10-17 11:02 ollehar File Added: ExamplePlugin.php
2016-10-17 11:03 ollehar File Added: ExamplePlugin-2.php
2016-10-17 11:03 ollehar Note Added: 41385
2016-10-17 11:03 ollehar Note Added: 41386
2016-10-17 11:05 ollehar Note Added: 41387
2016-10-17 11:06 ollehar File Deleted: ExamplePlugin-2.php
2016-10-18 21:30 TonyM Note Added: 41450
2016-10-18 21:38 TonyM Note Added: 41451
2016-10-18 23:46 DenisChenu Note Added: 41453
2016-10-19 10:16 ollehar Note Added: 41460
2016-10-19 10:37 ollehar Status assigned => resolved
2016-10-19 10:37 ollehar Resolution open => fixed
2016-10-19 10:37 ollehar Fixed in Version => 2.54
2016-10-19 11:33 ollehar Changeset attached => LimeSurvey master 6a432f99
2016-10-19 11:33 ollehar Note Added: 41480
2016-10-21 10:41 c_schmitz Note Added: 41517
2016-10-21 10:41 c_schmitz Status resolved => closed