Using process function several time bug, Editor PHP 1.6.1

Using process function several time bug, Editor PHP 1.6.1

perrotinperrotin Posts: 39Questions: 9Answers: 1
edited January 2017 in Editor

Hello Allan,

Thanks a lot for all the improvement in last version of Editor, it really helps a lot.

I noticed a little bug when upgrading to version 1.6.1, but it may result from a wrong usage.
I'm using Editor in Standalone mode, with submit option set to "changed".
As a consequence when I'm using "setFormatters" in Editor PHP, the $data parameter only contains the changed data submitted to POST.
What I was doing is using Editor to retrieve the other data from the current $id row like this :

$editor->where('myTable.id', $id ,'=');
$result = $editor->process( array() )->data();
$data = $result ['data'][0] ;

Since I've updated to 1.6.1 I have the following notices :

Notice: Undefined index: error in .../Editor-PHP-1.6.1/php/Editor/Editor.php on line 925
Notice: Undefined index: ipOpts in.../Editor-PHP-1.6.1/php/Editor/Editor.php on line 929
Notice: Undefined index: cancelled in .../Editor-PHP-1.6.1/php/Editor/Editor.php on line 933

These notices appear when _process( ) method is called for the second time, because the indexes have been unset at the end of _process() l920, when it ran for the first time.
Just reinitialising the $this->_out property at the begining of _process() method solved my problem.

I'm aware that the use I'm doing of this method is a little bit awkward, but it was working.
It would perhaps be best to have a public method get() to retrieve the data from a given row.

Or maybe I'm missing something here.

Thanks for your help

JULIAN

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    Answer ✓

    Hi Julian,

    Are you reusing the same Editor instance (i.e. calling process() on the same instance twice)? If so, that's not something that I had anticipated being done nor planned for.

    It would probably be best to rebuild the _out array in the process() method rather than _process() since _out can be used in the host process() method.

    I don't really see any issue with doing that - thanks for the suggestion. I'll have that in 1.6.2.

    Allan

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    Just to quickly confirm - this change will indeed be in 1.6.2 when it is released - hopefully later this week.

    Allan

This discussion has been closed.