Support » Plugin: Email Users » email-usrs.php L:660 & 674 error

  • Resolved WCVendors

    (@wcvendors)


    Howdy Mike,

    Great plugin. Been using it for a very long time.

    After updating from an old version to the latest, clicking Email Users > Send to Users or Send to Group displays a blank select list with no content below it and the following errors in /wp-admin/error_log

    [19-Jan-2016 18:22:21 UTC] email-users.php::660
    [19-Jan-2016 18:22:21 UTC] email-users.php::674
    [19-Jan-2016 18:22:27 UTC] PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 64 bytes) in /home3/XXXXXXXX/public_html/wp-includes/wp-db.php on line 2350

    The memory limit is 256MB which is pleeeeeeenty. WooCommerce, BuddyPress, and a few other useful plugins but nothing terribly special. There are 8000 users on the site, and 6 roles.

    Any ideas?

    Cheers

    Ben

    https://wordpress.org/plugins/email-users/

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Mike Walsh

    (@mpwalsh8)

    There was a database query problem a while back which would only show up on sites which had lots of users and 8000 users is in that ballpark. If you look at the HTML source for the page where the error occurs you should see something like this (the line numbers may be slightly different):

    <!-- email-users.php::1246 -->
    <!-- email-users.php::1247 -->
    <!--
    Array
    (
        [total_users] => 1285
        [avail_roles] => Array
            (
                [administrator] => 1
                [contributor] => 4
                [editor] => 2
                [subscriber] => 1277
                [none] => 1
            )
    
    )
     -->
    <!-- email-users.php::1249 -->
    <!--
    Array
    (
        [exclude] => Array
            (
                [0] => 1
            )
    
        [fields] => all
        [offset] => 0
        [number] => 500
    )
     -->
    <!-- email-users.php::1251 -->
    <!-- email-users.php::1270  Query #1  Memory Usage:  14M -->
    <!-- email-users.php::1270  Query #2  Memory Usage:  18.5M -->
    <!-- email-users.php::1270  Query #3  Memory Usage:  22.75M -->
    <!--
    1282 -->
    <!-- email-users.php::1304 -->

    This tells us how much memory the query is consuming. Email Users will do a user query in chunks of 500 users to prevent consuming all of the memory.

    Can you tell me what your numbers look like?

    WCVendors

    (@wcvendors)

    Thanks Mike.

    On the Send to Group(s) page, the very last line in the HTML source is:

    <select data-placeholder="Choose Group Recipients ..." class="mailusers-select" id="send_targets" name="send_targets[]" multiple="multiple" size="8" style="width: 654px; height: 250px;">

    On the Send to Users page, the very last line in the HTML source is:

    <select data-placeholder="Choose User Recipients ..." class="mailusers-select" id="send_users" name="send_users[]" size="8" style="width: 654px; height: 250px;" multiple="multiple" >

    The Memory Usage comments appear nowhere in the source…….

    Plugin Author Mike Walsh

    (@mpwalsh8)

    Oops. Forgot one critical thing – you need to enable Email Users debug mode to see the debug info I referenced above. Debug Mode is a checkbox on the Email Users settings page (Dashboard > Settings > Email Users).

    Don’t leave it enabled indefinitely as it may interfere with other email operations of your site.

    WCVendors

    (@wcvendors)

    Thanks. The plot thickens:

    Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 72 bytes) in /home3/xxxxxxx/public_html/wp-includes/class-wp-user-query.php on line 557

    That’s the error when going to /wp-admin/options-general.php?page=mailusers-options-page

    Memory is 256M in wp-config and confirmed with phpinfo.

    Plugin Author Mike Walsh

    (@mpwalsh8)

    How much user meta data does each of your users have? That is the only thing I can think of which would cause this to happen. If you are comfortable editing the plugin source code, you could try changing the value on line 1186 of email-users.php from 500 to 100 to see if the query completes. If it does, then I can make that value a setting that can be changed.

    WCVendors

    (@wcvendors)

    Hi Mike,

    Each user probably has a fair amount of users meta, since there is WooCommerce, and BuddyPress, on the site.

    WooCommerce stores a fair amount of users meta for billing name, address, city, phone, shipping name, address, city, phone, permissions they are in, access to downloads.

    BuddyPress also uses users_meta for storing a lot of BuddyPress related data, such as groups in, notifications, things like that.

    I changed the 'number' -> '100', and no change. But that’s when I noticed the //'fields' => array('ID', 'display_name', 'user_email'), and 'fields' => 'all',. I moved the comment out of all and moved it to the 3 key array and now the settings page actually loads without puking memory errors. And also with the fields => all commented out and the line above it uncommented, now the send to groups page actually loads, too.

    The more and more I look at the code executing the queries loading all of the fields is most likely the culprit of the memory issues if users_meta is populated. The number > 100-500 might help some, but overall, the all fields is the biggie.

    WCVendors

    (@wcvendors)

    PS — It does take about 45 seconds for the send to groups page to load, but it DOES load. I havent sent any emails with it yet, though. 🙂

    Plugin Author Mike Walsh

    (@mpwalsh8)

    I have no doubt that the “all” fields is causing memory to be exhausted. The line which was commented out was there for a reason but I cannot for the life of me remember why I commented it out. I suspect the commented out line is what I wanted to do but in a prior version of WordPress it didn’t work correctly. It is possible the problem I ran into has been fixed. It was a while ago that I implemented the query limit, it would take me a while to go back and figure out what version of WordPress was current at that time.

    When you uncommented the 3 key array did you still have the query limit set to 100? If so, try changing it back to 500 and see if the page loads? I suspect it will and it should be about 5x faster or close to it. With 8000+ users you’re looking at 80 database queries with it set to 100 vs 16 queries with it set to 500.

    When it completes, how do the memory stats look in the HTML source?

    WCVendors

    (@wcvendors)

    Hi Mike,

    Sorry for the delay, we had a big update to our own plugins and that took me out for support for those for a while.

    Changing the number from 100 to 500 did indeed increase the responsiveness of the form to around 15 seconds, not too terrible at all. I would imagine eventually the user base would grow to be so large that sending, say, 15,000 emails through wp_mail all at once would not be the wisest of moves anyway and force a plugin change. But hey, till that happens, I’m yours. 😉

    Memory stats looked good, no issues there at all.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘email-usrs.php L:660 & 674 error’ is closed to new replies.