?
avatar laoneo
laoneo
18 Jun 2016

Steps to reproduce the issue

  • Joomla should not run with ore than 128M of ram. But perhaps the error happens also with more.
  • Add the following XML code to the file administrator/components/com_content/models/forms/article.xml in the attribs section after line 152.
<field name="myintegervalue" type="integer" default="Some integer" label="Choose an integer" description="" first="1" last="99999" step="1" />
  • Open the article on the back end.

Expected result

No memory limit error.

Actual result

The following error hapens:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 80 bytes) in /joomla/libraries/cms/html/select.php on line 495

System information (as much as possible)

  • Joomla 3.5.1
  • PHP 7.0.6
  • 128 Mb Ram

Additional comments

Issue was discovered in the custom fields project joomla-projects/custom-fields#120.

avatar laoneo laoneo - open - 18 Jun 2016
avatar ggppdk
ggppdk - comment - 18 Jun 2016

if the field is used like that then you will have

  • 100,000 function calls to JHtml::_('select.option', ...

so 128 MBytes of memory being exhausted is expected

// Build the options array.
for ($i = $first; $i <= $last; $i += $step)
{
    $options[] = JHtml::_('select.option', $i);
}
  • then IF execution succeeds we get size of the produced HTML to be about 3.5 - 3.6 MBytes, which is again not good

i think the field was never intended to be used like this, best policy is to disallow such usage,

  1. Use '<select>'** for a sane limit of last - first < 1000
  2. do not use function call ... JHtml::_('
  3. if more than 1000 (or if some flag is set) then change display to be '<input />'

then also introduce a new JS validation type "integer"

<input ... class="validate-integer" data-first="0"  data-last="99999" />

Finally probably it is time that Joomla added an input validation masking JS library, i am sure this will be added eventually, it is just being delayed

avatar ggppdk
ggppdk - comment - 18 Jun 2016

Also another option is to use HTML5 form validation options
but currently joomla makes it hard to use this

Still, i think, adding an input validation masking JS library is best choice

avatar brianteeman brianteeman - change - 18 Jun 2016
Category Fields
avatar brianteeman brianteeman - change - 18 Jun 2016
Labels Added: ?
avatar brianteeman brianteeman - change - 27 Jun 2016
Status New Confirmed
avatar brianteeman brianteeman - change - 3 Aug 2016
Status Confirmed Closed
Closed_Date 0000-00-00 00:00:00 2016-08-03 16:48:56
Closed_By brianteeman
avatar brianteeman brianteeman - close - 3 Aug 2016
avatar brianteeman
brianteeman - comment - 3 Aug 2016

I am going to close this as no one would ever be creating an integer field like that


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/10861.

Add a Comment

Login with GitHub to post a comment