Custom Module: Save failed - The content exceeds allowed limits Topic is solved

For Joomla! 3.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderators: ooffick, General Support Moderators

Forum rules
Post Reply
deeno
Joomla! Intern
Joomla! Intern
Posts: 65
Joined: Fri Nov 03, 2006 1:07 pm

Custom Module: Save failed - The content exceeds allowed limits

Post by deeno » Mon Oct 02, 2023 8:09 am

Dear community,

we have a project running currently on J! 3.10.11 and already on migration planning to J!4, so hopefully this will be completed by end of 2023.

Problem is, there is this custom module, and the customer is (mis)using it by adding loads of content. Last week, the error message "Save failed with the following error: The content exceeds allowed limits" appeared.

We did some online research and it was suggested to change the params field inside the database > modules table, from "text" type to "mediumtext" or even "longtext". We tried both and it was not working. After further investigation, we found a post claiming, that this would not work, because J! build in a check in the code, preventing large content, no matter what the DB text type is.

We know it is not advisable to change code in core, but as it is vital to add more content via this custom module, and since we are going to switch to J!4 by the end of the year (where the present custom module solution will be rebuilt with just articles), we are willing to adjust the code in order to remove this limitation.

Anybody has any idea, where to change this, and if this change would/could affect also other parts of the system?

Alle best and thanks in advance,
D.

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 17445
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: Custom Module: Save failed - The content exceeds allowed limits

Post by toivo » Tue Oct 03, 2023 4:13 am

deeno wrote:
Mon Oct 02, 2023 8:09 am
J! build in a check in the code, preventing large content, no matter what the DB text type is.
That is correct. Both Joomla 3 and Joomla 4 check the length of the data before it is stored into the columns content and params. The check is hard coded in the file libraries/src/Table/Module.php:

Joomla 3.10.12 from line 126:

Code: Select all

	// Prevent to save too large content > 65535 
	if ((strlen($this->content) > 65535) || (strlen($this->params) > 65535))
	{
		$this->setError(\JText::_('COM_MODULES_FIELD_CONTENT_TOO_LARGE'));

		return false;
	}
Joomla 4.3.4 from line 141:

Code: Select all

        // Prevent to save too large content > 65535
        if ((\strlen($this->content) > 65535) || (\strlen($this->params) > 65535)) {
            $this->setError(Text::_('COM_MODULES_FIELD_CONTENT_TOO_LARGE'));

            return false;
        }
If you change the type of one or both of the columns content and params in the database schema from TEXT to MEDIUMTEXT and comment out the test in the code, the columns can be up to 16777216 or 16MB, at least in theory. Changes like this can have repercussions elsewhere and that is why core changes are not recommended.

Ref. MySQL 8.0 reference manual :: 11.7 Data Type Storage :: String Type Storage Requirements
Toivo Talikka, Global Moderator

deeno
Joomla! Intern
Joomla! Intern
Posts: 65
Joined: Fri Nov 03, 2006 1:07 pm

Re: Custom Module: Save failed - The content exceeds allowed limits

Post by deeno » Sat Oct 07, 2023 3:56 pm

Great stuff Toivo! Many thanks, it worked like a charm. We did not comment out the part, instead doubled it to 131070. All best, D.

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 17445
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: Custom Module: Save failed - The content exceeds allowed limits

Post by toivo » Sat Oct 07, 2023 11:25 pm

Cheers. As you can see, Joomla 4 has the same check and therefore your plan to use articles instead of modules makes sense.
Toivo Talikka, Global Moderator


Post Reply

Return to “Joomla! 3.x Coding”