Jump to content

Peter Falkenberg Brown

Members
  • Posts

    347
  • Joined

  • Last visited

  • Days Won

    4

Posts posted by Peter Falkenberg Brown

  1. Hi Folks,

    I've been trying to figure this one out for quite some time, with the help of my hosting company, but have not yet found a solution.

    One of the accounts I work on is running PW v 2.3.0 on a load-balanced, two node Linux system.

    The home page is deliberately plain, i.e. completely empty of content (since it's only a backend application with no front-end presence.)

    I say that to clarify that the home page is tiny, with no extra database calls.

    [edit: by backend app, I mean that it's a front-end app with a login. Only the home page and a login page are available to the guest user.]

    The load balancer hits the home page on both nodes about every 30 seconds, as a health monitor check.

    Since it hits "/", it's my assumption that it pulls the index.php file and displays the empty home page.

    The home page is viewable by guests, which is reflected in the error message below.

    For the last few weeks, I've received intermittent "MySQL server has gone away" errors, with the email coming from both of the nodes.

    They tend to be clumped together, e.g. 5 or 10 in a few minutes, and then they stop.

    The error messages come in from once a day to 4 or 5 times a day, and don't seem to have any correlation to server activity (that I've found so far.)

    I naturally thought that the error was simply revealing that the connected MySQL cluster was having trouble, but the host admin did a lot of checking of the logs around the times of those errors and doesn't show any MySQL problem.

    We've logged into the back end many times without any errors. The plain home page also doesn't show errors.

    I don't know if it's a 'guest' session problem or not. I turned on debug mode and the message expanded to what I've pasted below.

    Any brilliant, genius thoughts would be deeply appreciated.

    Peter (see error message below)

    =============

    Page: /?/
    User: ?

    Error:
    Exception: MySQL server has gone away

    SELECT false AS isLoaded, pages.templates_id AS templates_id, pages.*, pages_sortfields.sortfield, (SELECT COUNT(*) FROM pages AS children WHERE children.parent_id=pages.id) AS numChildren,field_email.data AS `email__data`
    FROM `pages`
    LEFT JOIN pages_sortfields ON pages_sortfields.pages_id=pages.id
    LEFT JOIN field_email ON field_email.pages_id=pages.id
    WHERE pages.parent_id=29
    AND pages.templates_id=3
    AND pages.id IN(40)
    GROUP BY pages.id  (in /home/user_account/public_html/wire/core/Database.php line 118)

    #0 /home/user_account/public_html/wire/core/DatabaseQuery.php(84): Database->query(Object(DatabaseQuerySelect))
    #1 /home/user_account/public_html/wire/core/Pages.php(319): DatabaseQuery->execute()
    #2 /home/user_account/public_html/wire/core/PagesType.php(109): Pages->getById(Array, Object(Template), 29)
    #3 /home/user_account/public_html/wire/core/Users.php(60): PagesType->get(40)
    #4 /home/user_account/public_html/wire/core/Session.php(82): Users->getGuestUser()
    #5 /home/user_account/public_html/
     

    ============

  2. Dear Ryan,

    After wrestling with a WordPress installation at work, I have come to even more deeply appreciate ProcessWire. Like I tell my children, "If I love (PW in this case) any more, I'll melt." So that's a quotable quote. :-)

    "If I love ProcessWire any more, I'll melt."

    Not only does ProcessWire purge the cache of the home page and the parents of an edited or added article, it also refreshes the cache on the paginated section pages. WordPress does not do that, with the W3TC plugin, or the WP Varnish plugin (according to our WordPress person.)

    At http://significatojournal.com, I've set up paginated section pages of articles, and tonight I tested the template caching option:

    "Clear cache for the saved page and parents (including homepage)"

    After testing adding an article, the paginated section pages correctly moved the last article on the page to the next page, and shuffled the next pages as well. When I deleted the test article, the section pages all shuffled back. Zowie.

    For this WordPress installation, we'll have to revise one of the plugins to do that.

    Have I said I like ProcessWire? Kudos, Ryan, and all the Brilliant, Genius Contributors!

    Peter

    • Like 7
  3. Hi Ryan and All,

    Not sure if it's too late for v2.4, which I'm really excited about, but I'm wondering if the new admin pages could include a link at the top, next to search, to display the most recently added or edited pages. It's very convenient when one has to log back in and make a change to a recent article. It's quicker than search.

    MODX Evo has it, and it would be nice for PW to have it too.

    Just a thought. :-)

    Peter

  4. Dear Teppo,

    Thanks for this info. I'll study it. I ran this query:

    SELECT 
      TABLE_NAME,
      COLUMN_NAME,
      CHARACTER_SET_NAME,
      COLUMN_TYPE
      COLLATION_NAME
    FROM information_schema.COLUMNS
    WHERE TABLE_SCHEMA = 'my_database_name'
    ORDER BY character_set_name,table_name,column_name
    

    and noticed that the varchar/text fields were all utf8, even though the db was latin1, including default fields like field_body.data, as well as custom fields.

    One thing that seems very pertinent, is that the characters display correctly in edit mode, but not view mode.

    That seems to indicate that the characters *can* be displayed properly. However, when I go to the PW admin page and view the source, I don't see anything unusual, i.e. it has the charset set to utf-8. The doctype is only 'html', and I tried that, with no difference.

    And the question remains: what impact does this have in PW's scheme of things, to have a Latin1 database, but some fields set as utf8? etc...

    Thanks,

    Peter

  5. Hi All,

    After SiNNuT's excellent help in this post: (thank you, SiNNuT),

    http://processwire.com/talk/topic/5400-tinymce-converting-html-entities-to-characters/

    I ran across a new situation -- or more accurately -- a new knowledge gap that I wish I didn't have. :-)

    I have another PW install, in which the curly quotes are not displaying properly, even though the header includes the line:

    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    

    I was digging around, and noticed that I had installed PW into a database that I had created, set to:

    * charset: latin1

    * collation: latin1_swedish_ci

    instead of utf8 and utf8_general_ci.

    Now, just to be clear, one of my PW installs with the latin1 charset does display the curly quotes correctly, so I'm not sure why the other install does not. I'm not entirely sure if the db charset and collation are the issue, or something else. And that's an item to solve.

    But my main questions here are:

    - Is the issue of installing PW into a latin1 db a huge problem? (It would be really great if the PW install prompted one to make sure that the db had the right charset. Or maybe it did, and I missed it.)

    - If it is a problem, does anyone have any tips on converting the db, tables and content appropriately?

    I'm under the impression that one could relatively easily convert the db and tables to utf8, but that the content would have to be converted as well -- perhaps using the PHP inconv function, as Ryan pointed out in another post?

    $newPage->title = iconv("ISO-8859-1", "UTF-8", $row['HEADLINE']);
    

    That sounds like a lot of effort and processing: having to convert every field of every page.

    As I mentioned, I have one install with latin1 where everything seems to be working okay. So maybe no conversion is necessary. ??

    It's that one other install, where the curly quotes aren't showing up in view mode, that has me baffled.

    What's really weird with that one, is that when I click on edit, either in the admin, or in my front end data form, the typographic curly quotes display correctly. It's only in view mode that they turn into this (in the source), with the page charset set to UTF-8:

    �test�

    the above text should be:

    “test” (i.e. "test" with curly quotes)

    By the way, the particular field I'm testing is set to be textarea only -- no TinyMCE at all.

    => As a related item, the problematic database receives email from a variety of email programs, from both PCs and MACs, and then saves the data to PW. Thus, things like curly quotes could be coming from a variety of machines.

    My Processwire script to save those pages does not include any type of charset declaration or conversion, because I was under the impression that I didn't need to do that. But that might be another knowledge gap.

    The test I did above, however, was me pasting in the word "test", with curly quotes, from LibreOffice Writer, on a PC.

    Thanks for all the help!

    I do intend to one day answer some questions myself, when I become more proficient in PW.

    (Well, I have posted one Case Study, so far.) :-)

    Peter

  6. Dear SiNNuT,

    By the way, based on your excellent comment that since ProcessWire stores everything as UTF-8, and the link at StackOverflow that you listed, which then led me to this article (from 2003!):

    "The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)", by Joel Spolsky

    http://www.joelonsoftware.com/articles/Unicode.html

    I educamated myself, and said, "Duh", and realized, as you so correctly pointed out, that I don't need the entities anyway.

    I just need to make sure I have this line in my templates:

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    

    When I checked, I was already using that line. So, I'm removing my entity declaration from TinyMCE.

    Sigh. One learns something every day. One hopes.

    Well... better to do it correctly now, than to continue in ignorance. :-)

    Addendum: and then one reads an article like this:

    http://line25.com/articles/10-html-entity-crimes-you-really-shouldnt-commit

    which says that one should use html entities. Lot's of opinions.

    But I just checked, and after removing my TinyMCE entity declarations, and purging my cache, and re-logging in,

    I was able to paste a copyright symbol in the body text, and it displayed correctly -- no entity needed.

    Thank you again, for your help.

    Peter

    • Like 1
  7. Dear SiNNuT,

    I removed the quotes, and replaced the missing numeric, but it didn't work until I cleared my cache; and then it did.

    I'm not sure if it was the quotes or the out of order list, but I'd bet it was the list. I was missing one number.

    Thank you! I really appreciate it. I now works like a charm.

    You wrote:

    Have you tried setting it to 'named'? Mind you, PW being a UTF-8 project i don't think this setting is desirable, but you could (and probably should) pair it with the entities option http://www.tinymce.c...ration:entities to make your own list.

    Could you elucidate more about the UTF-8 / named entity issue, and its impact? Would it make a difference if I used "numeric" instead of named?

    I always thought that the entities were preferable to raw characters, because someone pasting in an article from a PC might paste characters that weren't viewable on a MAC, and vice versa. I've seen curly quotes look all garbled on web pages, and in emails, so I thought that the entities bypassed the problem.

    I use LibreOffice on a Win7 machine, by the way.

    Thanks!

    Peter

  8. Dear SiNNuT,

    In the body fields Input settings, under 'Additional TinyMCE Settings', I added this:

    apply_source_formatting:true
    entity_encoding:named
    entities:'169,copy,8482,trade,ndash,8212,mdash,8216,lsquo,8217,rsquo,8220,ldquo,8221,rdquo,8364,euro'
    

    Then, I went to a page and clicked on the Edit HTML Source icon and added this:

    It’s not clear if this will work.
    

    When I hit update, it displayed a single curly quote, but when I went back into the HTML source, the ’ code had been replaced by a curly quote.

    I understand the concepts: I guess I'm either doing something wrong, or, does the InputfieldTinyMCE.js file need to be edited? Which I realize would be an edit to the core...

    Thanks for your help!

    Peter

  9. Hi All,

    I've noticed that when I paste HTML text into the HTML code view of the body field, and when that HTML text contains html entities, such as "’", and then click update, PW / TinyMCE converts the entity into a character.

    I'm not talking about the primary display view of the body field. What I mean is that when I go *back* into the code view, the entity is gone, and all I see are the characters.

    I thought it might be my install, with some misconfiguration, but I also tested it on the PW Skyscraper demo, in the body field, and it did the same thing.

    My goal is to paste text from LibreOffice Writer, that has curly quotes, etc, in the body field, and have TinyMCE convert those characters to entities. If that can't be done, I at least want to be able to paste converted HTML text into the code view, and NOT have TinyMCE convert them back, as it seems to be doing.

    I've Googled around, and tried various TinyMCE config settings, to no avail.

    Any clues?

    Thanks!

    Peter

  10. Dear SiNNuT,

    Thanks for that link. I see that your solution was based on this comment:

    Teo wrote:

    One thing I don't get. Why do we need to generate a random ID at all??? While can't we get the number of rows (rather than max(id)), generate a

    random POSITION (rather than a random id), and then use that position as the first argument of LIMIT (being 1 the second argument)
    ???
    Am I missing something?

    Did that once. Works quite well, even on not uniformly distibuted ID values, but only if you want to fetch a single row. Still, you need to generate one random number per row either way.

    I agree with your idea - it seems very practical on large data sets.

    I'll give it a shot, and see how it performs.

    Thanks again,

    Peter

  11. Dear Soma,

    Thanks! That's a much cleaner coding method. I revised my code, per your suggestion above.

    I'm curious: how does "sort=random" work, internally? Does it use the MySQL "ORDER BY RAND()" code? Do you think that that method works okay, even with thousands of records? It would seem to me that it would have to create a random number on the fly for each record.

    Also, about the cache: thanks for that. I had forgotten that I had set the cache on that template to only cache for guests, and I was logged in, which thus displayed the headlines refreshing every time I hit reload.

    Since my pages are set to cache only for one day, I think that it will be okay, because the headlines will change once a day, which is fine.

    Thanks for your help!

    Peter

  12. Hello All,

    I've added a "Random Articles" block to the bottom of our article pages, at The Significato Journal.

    The block is under the headline at the bottom, called:

    "More Headlines You May be Interested In"

    I have some questions:

    a) Is my code efficient and the best method to display 4 random headlines? It's of special concern if a site eventually has tens of thousands of articles, because I'm creating an array of all of the articles pages, and then grabbing 4 random ones. It would be better, I think, if I could create an array of only 4, but I don't see how I can do that and still randomly select from all of them. Here's my code:

    $random_selectors = "custom_template_file.select_value=article_page.php," .
                        "publish_date<=$now, headline_image_name!=";
    
    $random_keys      = wire('pages')->find("$random_selectors");
    $random_pages     = $random_keys->findRandom('4');
    
    echo "<table width='100%' cellpadding='0' cellspacing='10'><tr>";
    
    foreach ( $random_pages as $random_page )
          {
          # ... display headline and image
          }
    
    echo "</tr></table>";
    

    b) Every time I reload an article, the headlines change, which is what I want.

    Does this break the 1-day template cache on the article, or does the headline block get passed through, with the rest of the page still cached? I'd like to keep the cache running.

    Here's a sample url, so that you can see it in action:

    http://significatojournal.com/columns/culture-of-heart/the-living-compass-of-kindness-and-compassionate-love/

    Thanks for any feedback!

    Peter

  13. Dear Martijn and Teppo,

    Here's one more question. I got the Magnific function working, but I've been scouring the docs and Google, and I haven't figured out how to grab the image description (the one that PW stores) and display it as a caption. I've tried a number of things, to no avail. The images are showing the description in the alt field, however.

    This is my code, at this point, without any caption code.

    <script>
    $(function() {
      $('a[href*="/assets/files/"]:has(img)').addClass('sj_image_popup')
      $('.sj_image_popup').magnificPopup({
      type: 'image',
      closeOnContentClick: true,
      });
    });
    </script>
    

    Any thoughts on that?

    Thanks!

    Peter

  14. Dear Martijn and Teppo,

    Aha! I was caught by the Evil Cache Monster. I had turned on caching, and even when I cleared my browser cache, and reloaded the page, it wasn't working because -- silly me -- it was still reading the old page, with the old header. Sigh.

    So, now, it Works!! You guys are great! Brilliant, Creative, and well, Great. :-)

    This is a much better solution than a hook, or a script to try to insert a class in the hrefs at run time (which I tried, ugh).

    Now I just have to tweak the Magnific settings and I'm rocking and rolling. Thank you both very much, once again.
    To review, with your input, perhaps, this is my final code:

    <script type="text/javascript" src="<?php echo $template_url?>scripts/jquery-1.10.2.min.js"></script>
    
    <link rel="stylesheet" href="<?php echo $template_url?>styles/magnific-popup.css">
    <script src="<?php echo $template_url?>scripts/jquery.magnific-popup.min.js"></script>
    
    <script>
    $(function() {
      $('a[href*="/assets/files/"]:has(img)').addClass('sj_image_popup')
      $('.sj_image_popup').magnificPopup({type:'image'});
    });
    </script>
    

    So as to not confuse things, I changed the class name from 'InputfieldFileLink', since this code now has nothing to do with ProcessWire's classes (correct me if I'm wrong).

    Peter

    • Like 3
  15. Dear Martijn and Teppo,

    I've added a new jquery file and the Magnific files.

    I've played around with the order of the files, testing in different ways, but it still doesn't work.

    Could you have a look at the link?

    http://significatojournal.com/help-the-world/freedom-human-rights/help-to-end-the-unbearable-evil-of-modern-slavery/

    I'm probably missing something.

    Thanks!

    Peter

  16. Dear Teppo,

    The link is:

    http://significatojournal.com/help-the-world/freedom-human-rights/help-to-end-the-unbearable-evil-of-modern-slavery/

    I moved the code block just before the inputimagefield.js, and reloaded, but no go...

    Thanks SO much for your help. Of course, this will create a solution for everyone who wants to use the Fancybox system. :-)

    Peter

  17. Dear Martijn and Teppo,

    I think this solution is brilliant and creative!

    Now I just have to get it to work. :-) My Javascript is weak.

    I added the script snippet to my <head> area, minus this line:

    $(".InputfieldFileLink").whatEverLightBoxYouLike();

    It didn't change anything. Do I need the line above, and how would I edit that for Fancybox?

    Because, as it stands now, if the class is added manually, the Fancybox popups work.

    This is what I have:

    <script type="text/javascript" src="<?php echo $template_url?>scripts/jquery-1.4.2.min.js"></script>
    <script type="text/javascript" src="<?php echo $template_url?>scripts/main.js"></script>
    
    <link type='text/css' href='/wire/modules/Jquery/JqueryFancybox/JqueryFancybox.css?v=126' rel='stylesheet' />
    
    <script type='text/javascript' src='/wire/modules/Jquery/JqueryCore/JqueryCore.js?v=183'></script>
    <script type='text/javascript' src='/wire/modules/Jquery/JqueryFancybox/JqueryFancybox.js?v=126'></script>
    <script type='text/javascript' src='/wire/modules/Inputfield/InputfieldImage/InputfieldImage.js?v=100'></script>
    
    <!--
    For the Fancybox to work, the hrefs that link to images need this class:
    <a class='InputfieldFileLink' href='xyz.jpg'>
    -->
    
    <script>
      // document ready
      $(function(){
        // add class InputfieldFileLink, to every href that links to an image.
        $("a[href$='.jpg'], a[href$='.gif'], a[href$='.png']").addClass('InputfieldFileLink');
    
        // $('a[href*="/assets/files/"]:has(img)').addClass('InputfieldFileLink');
      });
    </script>
    

    I tried both variations of the addClass line, but each time when I refreshed the page,

    the popup didn't work, and when I looked at the source, the class wasn't in the image links.

    Best regards,

    Peter

×
×
  • Create New...