News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Is there a maximum size of <add> mod sections?

Started by 0897jhPEFUOIyG90, October 02, 2006, 09:47:04 AM

Previous topic - Next topic

0897jhPEFUOIyG90

Like the post title queries: Is there a maximum size of <add> mod sections?


<operation>
<search position="replace"><![CDATA[
// code to replace
]]></search>
<add><![CDATA[

// ***JUST HOW BIG CAN THIS CDATA BE?***

// code to replace
]]></add>
</operation>


I get the impression that the php xml parser limits CDATA to 1024 bytes and is called iteratively for larger CDATA items, though I'm not really sure if this is the case.

If there is a limit on how large an <add> mod section can be, what would be the simplest mechanism to replace whole exisiting smf files instead, or would that be a bad idea?

Or is it possible to put multiple CDATA items inside one <add> section in a mod xml file?

vbgamer45

I am not aware of a limit. I have seen some pretty big  add sections that insert entire functions into a file. I haven't seen anyone run into a problem with the size as of yet.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

0897jhPEFUOIyG90

Hmmm...

I've been testing my mod in stages adding a bit more each time, it always tests OK but on my last attempt it generates a 500 error on application.

Perhaps I've introduced an error in my latest addition or perhaps its an issue with the freehost I'm testing it on.

I guess I'll back up a few steps and see if I can pin it down.

Thanks for the info.

0897jhPEFUOIyG90

#3
It seems those 500 errors were the fault of the freehost I was testing on (probably a php memory limit or something). Attempting to install Tinyportal on that host gave the same result.

Once I started testing my mod on my local MySQL/Apache/PHP/eAcclerator install everything was fine.

HOWEVER...

...as I continued testing and the mod grew in size it appears there is a size limit:


Quote
/index.php?action=packages;sa=uninstall;package=mytestpackage.zip
Apply Filter: Only show the errors with the same message
2: preg_match() [<a href='function.preg-match'>function.preg-match</a>]: Compilation failed: regular expression too large at offset 0
File: \Sources\Subs-Package.php
Line: 1535

It was fine on installation, but generated this error on uninstallation.

preg_match and preg_replace functions in PHP are very cpu and memory intensive (the reason that SMF's search function chokes most servers on a database of any significant size).

I guess I need to find a new strategy, perhaps breaking the <add> sections into smaller pieces or just replacing the target files altogether (but that would result in more possible incompatibilities with other mods).

Dang!  :(

vbgamer45

Maybe it would be best to place all the code in an external file? Instead of adding to a file if you can.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

0897jhPEFUOIyG90

Quote from: vbgamer45 on October 03, 2006, 01:20:18 PM
Maybe it would be best to place all the code in an external file? Instead of adding to a file if you can.

Ah, good thought. Thanks for the suggestion!

Harzem

Have a look at the way Custom Profile Field mod works, it just includes and calls outer functions from outer files.

Or, you can divide the search & replace routine into pieces, which will result into the same replacement at the end.

BTW, are you sure your display name is not your password? :P

davidhs

I know this is a very old topic but I had this problem with help text of one of my mods (written by me) and it can be occurs with others mods. I write these steps for avoid this problem:

1. Before uninstall the old version of the mod, make a copy of the help file of the language of forum (FORUM/Themes/default/languages/Help.* php).

2. Uninstall the mod. No error alerts but if error has ocurred, it is showed in the error log and must be corrected with steps 3 and 4.
Quote
http://.../index.php?action=admin;area=packages;sa=uninstall2;package=THE_MOD.tar.gz;pid=38
2: preg_replace() [<a href='function.preg-replace'>function.preg-replace</a>]: Compilation failed: regular expression too large at offset 0
File: D:/Apache/htdocs/david/smf/smf/foros/smf_2_0_10/Sources/Subs-Package.php
Line: 2086

3. The help file is empty (size 0). Replace by the copy made in step 1.

4. Open the help file and remove all text added by the mod.





If you uninstalled the old version of mod and did not copy the help file, you can do nothing. Open your help file and if does not begin with

<?php

is corrupted, replace it by the original file from the corresponding language. You have lost the translation that could have added your mods, but if you reinstall mods it will recover (if not reinstall, you will see the help in English).

Oldiesmann

The easiest way around that is to simply include a separate language file with those strings in it for your mod. Just add them to a separate language file (and make sure "global $helptxt;" is at the top of the file), then make this change to Sources/Help.php:

Find
// Load the admin help language file and template.
loadLanguage('Help');


Replace
// Load the admin help language file and template.
loadLanguage('Help+YourFile');


Note the "+" - this is how you load multiple language files at once.
Michael Eshom
Christian Metal Fans

Kindred

in general, you should never be writing to the standard SMF language files anyway... you should either be including your own language file for the mod or be writing to modifications.english.php
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Advertisement: