We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 1578
    • 9 Posts

    Edited to add: The work-around I’ve found is documented a few posts down

    Hi all,

    I do hope this isn’t a terribly newbie problem:
    I’m using MODx Revolution 2.0.4-pl2.
    I log into the manager and create a new chunk. I give it a name, a description and some content.

    I press save, and get redirected to a page like:
    http://example.com/manager/index.php?a=10&id=2

    This looks completely blank. When I view source, it shows this:
    [tt]<script type="text/javascript">
    // <[CDATA[
    Ext.onReady(function() {
    Tiny.config =
    [/tt]

    When I uninstall tinymce, the chunk displays correctly.
    The uninstall script complained about a missing table. When I repeat this install / uninstall, there is no complaint about a missing table, just the following:

    [tt]Skipping modPluginEvent object (data object does not exist and cannot be removed): Array ( [pluginid] => 0 [event] => OnRichTextBrowserInit )
    Removed modPluginEvent instance with primary key Array ( [0] => 2 [1] => OnRichTextBrowserInit )
    Skipping modPluginEvent object (data object does not exist and cannot be removed): Array ( [pluginid] => 0 [event] => OnRichTextEditorRegister )
    Removed modPluginEvent instance with primary key Array ( [0] => 2 [1] => OnRichTextEditorInit )
    Removing files in file resolver: /path/to/web/public/assets/components/tinymce
    Removed modPlugin instance with primary key 2
    Package found. Preparing to uninstall.
    Removed modPluginEvent instance with primary key Array ( [0] => 2 [1] => OnRichTextEditorRegister )
    Finding package with signature: tinymce-4.1.2-rc1
    Skipping modPluginEvent object (data object does not exist and cannot be removed): Array ( [pluginid] => 0 [event] => OnRichTextEditorInit )
    Removed modSystemSetting instance with primary key tiny.path_options
    Removed modSystemSetting instance with primary key tiny.css_selectors
    Removed modSystemSetting instance with primary key tiny.editor_theme
    Removed modSystemSetting instance with primary key tiny.custom_buttons5
    Removed modSystemSetting instance with primary key tiny.custom_buttons1
    Removed modSystemSetting instance with primary key tiny.use_uncompressed_library
    Package successfully uninstalled with signature: tinymce-4.1.2-rc1
    Removing files in file resolver: /path/to/web/public/core/components/tinymce
    Removed modSystemSetting instance with primary key tiny.custom_buttons3
    Removed modSystemSetting instance with primary key tiny.custom_plugins
    Removed modSystemSetting instance with primary key tiny.theme_advanced_blockformats
    Removed modNamespace instance with primary key tinymce
    Removed modSystemSetting instance with primary key tiny.template_list
    Removed modSystemSetting instance with primary key tiny.custom_buttons4
    Removed modSystemSetting instance with primary key tiny.custom_buttons2[/tt]

    Like I say, uninstalling tinymce and reinstalling it does not solve the problem. Do you have any ideas what I can try?

    Many thanks for your help,
    Andrew.

    System info:
    MODx version: Revo Traditional 2.0.4-pl2
    Server: Solaris Nevada snv_65 X86
    PHP version: 5.2.12
    MySQL version: 5.0.90
    Browser: Firefox latest
    No opcode cache
    No core/cache/logs/error.log.
      • 3749
      • 24,544 Posts
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 1578
        • 9 Posts
        Sorry it’s taken me a while to get some more info on this. I looked into it being a mod_security thing, but it didn’t quite fit - no precondition failed. Once I turned up the logging, it turns out that my PHP process is running out of memory. I upped the per-process limit from 64MB to 149MB, and still run out of memory, so I’m pretty sure there’s a more serious root cause. Here are my error logs. I’m going to have a search around the forum for memory-related problems just now. If you’ve seen this before, I’d love to know what you think I could do.
        [tt][Sat Dec 11 21:57:23 2010] [warn] [client nn.nnn.nnn.nnn] mod_fcgid: stderr: PHP Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 60817461 bytes) in /my/server/web/public/core/xpdo/xpdo.class.php on line 1877, referer: http://example.com/manager/
        [Sat Dec 11 22:03:41 2010] [warn] [client nn.nnn.nnn.nnn] mod_fcgid: stderr: PHP Fatal error: Out of memory (allocated 138149888) (tried to allocate 131858493 bytes) in /my/server/web/public/core/xpdo/xpdo.class.php on line 1877, referer: http://example.com/manager/
        [/tt]

        Many thanks!
          • 1578
          • 9 Posts
          I’ve found this bug report that sounds quite familiar:
          http://bugs.modx.com/issues/2906

          It’s the same error but in a different context:
          When saving any normal web resource (ie. a web-page); saving crashes. This is because:

          Fatal error: Allowed memory size of 41943040 bytes exhausted (tried to allocate 82 bytes) in
          /core/xpdo/om/xpdoobject.class.php on line 616


          Here’s a similar one for the TinyMCE plugin:
          https://github.com/splittingred/TinyMCE/issues/#issue/26

          I assume this is TinyMCE related, but I’m really not sure where to go. I’m assuming that most people don’t have this, so could it be a problem installing TinyMCE?
            • 1578
            • 9 Posts
            Looks like somebody had the same problem in this thread:
            http://modxcms.com/forums/index.php/topic,53509.0.html

            I’ve looked at the xpdo.class.php line where the error occurs (1877) and modified it to use the fallback Json encoder. Putting some debugging in there suggested that the problem occurs when trying to json_encode the Tiny.config object which is about 3k characters. This isn’t the whole picture, as this must be parsed to display the resource editing pages too - and that happens without a hitch.

            New Question: Can I disable tinymce for chunks? It seems entirely unnecessary as it’s used by developers to write html. Tinymce doesn’t appear when I’m editing the chunks, so I’m not sure how it’s supposed to be involved.

            I’ve gone through some extra hoops to get here:
            Reinstalled from scratch - including new database.
            Installed old versions of tinymce package back to 4.0.5pl
            Enable eaccelerator
            Increased PHP memory per process to 128M and max processing time to 120s.

            Any suggestions or work-arounds welcome.
              • 1578
              • 9 Posts
              Putting debug code into the plugin (Elements -> Plugins -> TinyMCE -> Create / Edit Plugin) shows me that the plugin code does not even get executed before the out of memory error.

              The loading of the tinymce plugin should look the same for the resource and the chunk. Debug code to display the properties object that is causing this issue, the only differences between them are as follows (this is the output of the diff):
              [tt]< $thing["editor"]="";
              < $thing["elements"]=array(0=>"post");
              < $thing["chunk"]="";
              ---
              > $thing["editor"]="TinyMCE";
              > $thing["elements"]=array(0=>"ta");
              > $thing["id"]=1;
              > $thing["mode"]="upd";
              [/tt]

              The top one is the chunk, the bottom is the resource. ’thing’ refers to the properties object.

              There doesn’t seem to be anything there for json_encode to get bent out of shape about, is there?
                • 1578
                • 9 Posts
                I’ve found a way to disable the loading of tinymce config for chunks. I still don’t understand why the chunk editor has this issue, or why the rich text editor gets loaded for chunks when the [tt]which_element_editor[/tt] system setting is empty. The work-around is nasty and hacky, but it is mercifully short.

                The work-around modifies the script template, including some php code to check for the word ’element’ at the start of the namespace_path option.

                The file to be edited is [tt]core/components/tinymce/templates/script.tpl[/tt]. You can edit it using the MODx file editor or directly on the file system.
                This code:
                [tt]Tiny.config = <?php echo $this->modx->toJSON($this->properties); ?>;[/tt]
                Becomes this code:
                [tt]Tiny.config = <?php
                if (substr($this->modx->getOption(’namespace_path’), 0, 7) == ’element’) {
                echo ’{}’;
                } else {
                echo $this->modx->toJSON($this->properties);
                }
                ?>;
                [/tt]

                Here’s the file before modifying:
                [tt]<script type="text/javascript">
                // <[CDATA[
                Ext.onReady(function() {
                Tiny.config = <?php echo $this->modx->toJSON($this->properties); ?>;
                Tiny.config.setup = function(ed) {
                ed.onInit.add(Tiny.onLoad);
                ed.onKeyUp.add(Tiny.onChange);
                };
                Tiny.templates = <?php echo $this->modx->toJSON($templates); ?>;
                });
                // ]]>
                </script>
                [/tt]

                And after modifying:
                [tt]<script type="text/javascript">
                // <[CDATA[
                Ext.onReady(function() {
                Tiny.config = <?php
                if (substr($this->modx->getOption(’namespace_path’), 0, 7) == ’element’) {
                echo ’{}’;
                } else {
                echo $this->modx->toJSON($this->properties);
                }
                ?>;
                Tiny.config.setup = function(ed) {
                ed.onInit.add(Tiny.onLoad);
                ed.onKeyUp.add(Tiny.onChange);
                };
                Tiny.templates = <?php echo $this->modx->toJSON($templates); ?>;
                });
                // ]]>
                </script>
                [/tt]

                Here are some things to bear in mind:

                • Take a copy of the file before you change it
                • If you break it, you get to keep all the pieces - I take no responsibility. If I made a mistake in this code, I will not be held responsible for damages.
                • You will have to re-apply this whenever you upgrade tinymce (unless the issue is fixed)
                • The rich text editor will not appear for any elements
                • This namespace_path is not documented, so it might go away or change in a future version of MODx - I don’t know.
                • Your mileage may vary - I’ve tested this on exactly one setup. Good luck.

                I hope that’s of help to somebody.
                  • 3749
                  • 24,544 Posts
                  It appears that which_element_editor is never checked in the MODx code.

                  Could you report that as a bug using the Bugs & Requests link at the top of this page?
                    Did I help you? Buy me a beer
                    Get my Book: MODX:The Official Guide
                    MODX info for everyone: http://bobsguides.com/modx.html
                    My MODX Extras
                    Bob's Guides is now hosted at A2 MODX Hosting
                    • 1578
                    • 9 Posts
                    Quote from: BobRay at Dec 14, 2010, 11:49 AM

                    Could you report that as a bug...

                    Done - thanks, Bob!

                    Andrew.
                      • 1263
                      • 1 Posts
                      This is not a problem with chunk only. I have a little content of document:
                      <div id="mapa"><!--to jest mapa google -></div>
                      <div style="float: right; width: 240px;">
                      <p>{{adres}}</p>
                      <p>GPS: 51.210876, 16.166157</p>
                      <p>{{godziny}}</p>
                      <a href="http://www.facebook.com/profile.php?id=100001772072885&v=info" target="_blank"><img src="assets/images/facebook_login.jpg" alt="Mexico Bar na Facebook" /></a><br /><a href="mailto:[email protected]">[email protected]</a> </div>
                      

                      If I open this document in TinyMCE, after
                      <div id="mapa"><!--to jest mapa google -></div>
                      

                      no content is delivered at all, blank!!
                      If this first line is:
                      <div id="mapa"></div>
                      

                      after opening in TinyMCE, this line is blank, but everything after this is ok.
                      MODx 1.0.4 Evolution, Server Apache, OS Linux, MySQL 5.0.91, http://www.mexico-bar.com.pl