? Success

User tests: Successful: Unsuccessful:

avatar itbra
itbra
22 Jul 2014

It happens the JObject::_errors stack is asked to add entries with no data.
Take for instance JModelAdmin::save(). This method triggers two events while processing the store - event_before_save and event_after_save. The former event handlers' response is catched and evaluated. However, it is expected that the error that might have occured was thrown by the table object passed in. In fact the error should be expected from the dispatcher, since errors are either thrown directly by the plugin or set via $this->subject->setError where subject is the JEventDispatcher object. So the error setting block should be

// Trigger the onContentBeforeSave event.
$result = $dispatcher->trigger($this->event_before_save, array($this->option . '.' . $this->name, $table, $isNew));

if (in_array(false, $result, true))
{
   $this->setError($dispatcher->getError());
   return false;
}

This however might be one place where empty entries are added to JObject::_errors. So this block should additionally check for the error's existance.

if (in_array(false, $result, true))
{
   if ($dispatcher->getError())
   {
      $this->setError($dispatcher->getError());
   }
}

I'm sure there are many more places where this kind of empty error entries are produces and set. To circumvent this issue i added a short filtering of JObject::_errors to drop empty entries and thus error boxes with no content to be shown to the user.

Please let me know, what you think about it!

CLOSED (because this is the wrong file. Find active discussion and PR here)

avatar itbra itbra - open - 22 Jul 2014
avatar itbra itbra - close - 22 Jul 2014
avatar itbra itbra - head_ref_deleted - 22 Jul 2014
avatar itbra itbra - change - 22 Jul 2014
The description was changed
Description <p>It happens the _errors stack of JObject is asked to add entries with no data.<br> Take for instance <code>JModelAdmin::save()</code>. This method triggers two events while processing the store - event_before_save and event_after_save. The former event handlers' response is catched and evaluated. However, it is expected that the error that might have occured was thrown by the table object passed in. In fact the error should be expected from the dispatcher, since errors are either thrown directly by the plugin or set via <code>$this-&gt;subject-&gt;setError</code> where subject is the JEventDispatcher object. So the error setting block should be ```<br> // Trigger the onContentBeforeSave event.<br> $result = $dispatcher-&gt;trigger($this-&gt;event_before_save, array($this-&gt;option . '.' . $this-&gt;name, $table, $isNew));</p> <p>if (in_array(false, $result, true))<br> {<br> $this-&gt;setError($dispatcher-&gt;getError());<br> return false;<br> }</p> <pre><code> This however might be one place where empty entries are added to JObject::_errors. So this block should additionally check for the error's existance. ``` if (in_array(false, $result, true)) { if ($dispatcher-&gt;getError()) { $this-&gt;setError($dispatcher-&gt;getError()); } } </code></pre> <p>I'm sure there are many more places where this kind of empty error entries are produces and set. To circumvent this issue i added a short filtering of <code>JObject::_errors</code> to drop empty entries and thus error boxes with no content to be shown to the user.</p> <p>Please let me know, what you think about it!</p> <p>It happens the <code>JObject::_errors</code> stack is asked to add entries with no data.<br> Take for instance <code>JModelAdmin::save()</code>. This method triggers two events while processing the store - event_before_save and event_after_save. The former event handlers' response is catched and evaluated. However, it is expected that the error that might have occured was thrown by the table object passed in. In fact the error should be expected from the dispatcher, since errors are either thrown directly by the plugin or set via <code>$this-&gt;subject-&gt;setError</code> where subject is the JEventDispatcher object. So the error setting block should be</p> <pre><code>// Trigger the onContentBeforeSave event. $result = $dispatcher-&gt;trigger($this-&gt;event_before_save, array($this-&gt;option . '.' . $this-&gt;name, $table, $isNew)); if (in_array(false, $result, true)) { $this-&gt;setError($dispatcher-&gt;getError()); return false; } </code></pre> <p>This however might be one place where empty entries are added to JObject::_errors. So this block should additionally check for the error's existance.</p> <pre><code>if (in_array(false, $result, true)) { if ($dispatcher-&gt;getError()) { $this-&gt;setError($dispatcher-&gt;getError()); } } </code></pre> <p>I'm sure there are many more places where this kind of empty error entries are produces and set. To circumvent this issue i added a short filtering of <code>JObject::_errors</code> to drop empty entries and thus error boxes with no content to be shown to the user.</p> <p>Please let me know, what you think about it!</p>
Status New Closed
Closed_Date 0000-00-00 00:00:00 2014-07-22 13:37:21
Labels Added: ? ?
avatar itbra itbra - close - 22 Jul 2014

Add a Comment

Login with GitHub to post a comment