• Hi,

    as the title says, both “Add new” and “Edit” has been broken for us for a long time.

    (WP 5.9.2, WC 6.3.1, PHP 8.0.16)

    Both on Chrome and Firefox pressing the buttons only throws errors on the consoles:
    load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate,utils,moxiejs,plupload&ver=5.9.2: GET https://{our_url}/wp-admin/admin-ajax.php?action=wpf_edit&nonce={some_hex}&slug={some_filter} 500 (Internal Server Error)

    XHRGEThttps://{our_url}/wp-admin/admin-ajax.php?action=wpf_add&nonce={some_hex}
    [HTTP/1.1 500 Internal Server Error 403ms]

    I can open the URL Chrome quotes for the error in the browser and it’ll load the filter’s settings (page) without any formatting, but it’ll be without function and with an “There has been a critical error on this website.” on the bottom as well.

    This despite all other plugins apart from WooCommerce being disabled.

    Please advise.

    • This topic was modified 4 years, 2 months ago by isarisar.
Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Author themifyme

    (@themifyme)

    Hi,

    From the error it looks like you’re having an admin-ajax.php error, please contact your hosting provider about this, so they can fix it for you.

    Hi,

    I have the same problem, did you solve it?

    Thread Starter isarisar

    (@isarisar)

    Unfortunately I haven’t. This is the only plugin of our four dozen which has any issue.

    I’ve also tried with a local installation of WordPress on PHP 8.0.17 with 512MB available and otherwise default settings (apart from enabling the relevant extensions), no improvement.

    The same goes for me,
    it doesn’t work on my Divi site but it works fine on one of my other sites.
    I am on php 8, wordpress 5.9 and Divi theme.
    Maybe we can list our plugins and we can find the common plugin that is causing the problem?

    Thread Starter isarisar

    (@isarisar)

    Hi, I figured trying to run with debug enabled, it shows a repeated warning & subsequent error that doesn’t seem related to our server:

    PHP Warning:  Undefined array key "image_bg_641" in /srv/wp-content/plugins/themify-wc-product-filter/includes/class-wpf-form.php on line 1381
    PHP Warning:  Undefined array key "image_bg_642" in /srv/wp-content/plugins/themify-wc-product-filter/includes/class-wpf-form.php on line 1381
    PHP Warning:  Undefined array key "image_bg_646" in /srv/wp-content/plugins/themify-wc-product-filter/includes/class-wpf-form.php on line 1381
    PHP Warning:  Undefined array key "image_bg_643" in /srv/wp-content/plugins/themify-wc-product-filter/includes/class-wpf-form.php on line 1381
    PHP Warning:  Undefined array key "image_bg_645" in /srv/wp-content/plugins/themify-wc-product-filter/includes/class-wpf-form.php on line 1381
    PHP Warning:  Undefined array key "image_bg_644" in /srv/wp-content/plugins/themify-wc-product-filter/includes/class-wpf-form.php on line 1381
    PHP Fatal error:  Uncaught TypeError: floor(): Argument #1 ($num) must be of type int|float, string given in /srv/wp-content/plugins/themify-wc-product-filter/includes/class-wpf-form.php:407
    Stack trace:
    #0 /srv/wp-content/plugins/themify-wc-product-filter/includes/class-wpf-form.php(407): floor()
    #1 /srv/wp-content/plugins/themify-wc-product-filter/includes/class-wpf-form.php(331): WPF_Form->get_main_fields()
    #2 /srv/wp-content/plugins/themify-wc-product-filter/includes/class-wpf-form.php(278): WPF_Form->module()
    #3 /srv/wp-content/plugins/themify-wc-product-filter/admin/partials/form.php(7): WPF_Form->form()
    #4 /srv/wp-content/plugins/themify-wc-product-filter/admin/class-wpf-admin.php(343): include_once('...')
    #5 /srv/wp-includes/class-wp-hook.php(307): WPF_Admin->add_template()
    #6 /srv/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters()
    #7 /srv/wp-includes/plugin.php(474): WP_Hook->do_action()
    #8 /srv/wp-admin/admin-ajax.php(187): do_action()
    #9 {main}
      thrown in /srv/wp-content/plugins/themify-wc-product-filter/includes/class-wpf-form.php on line 407
    Thread Starter isarisar

    (@isarisar)

    Indeed, without me knowing the internals of the code, change in class-wpf-form.php at line 407…

    $min = floor(get_post_meta(get_the_ID(), '_price', true));
    if (empty($min)) {
        $min = 0;
    }

    to sth. like

    $min = get_post_meta(get_the_ID(), '_price', true);
    $min = empty($min) ? 0 : floor($min);

    … and it’ll work again.

    To remove the warning (originally) on line 1381, just adopt the empty() check already found two lines above…
    <img class="preview-image-wraper" src="<?php echo $module['image_bg_' . $cat->term_id] ?>" alt="">
    … to sth. like:
    <?php if (!empty($module['image_bg_' . $cat->term_id])): ?><img class="preview-image-wraper" src="<?php echo $module['image_bg_' . $cat->term_id] ?>" alt=""><?php endif; ?>

    Plugin Author themifyme

    (@themifyme)

    At point #8 it shows you the admin-ajax.php error as well: https://share.getcloudapp.com/OAu6QRGo that is the cause of the issue, you can first try to raise PHP Memory Limit: https://themify.me/blog/how-to-increase-php-memory-limit-for-wordpress – if this doesn’t help, then you should contact your hosting provider about this issue / ask them to fix the admin-ajax.php on your site, that should help.

    PS. Modifying the code may break some functionality of the plugin / it will be reverted after the updates, so it is not recommended.

    Thread Starter isarisar

    (@isarisar)

    That’s reading the stack trace the wrong way. The issue is floor() calls now being invalid with eg. implicitly convertible empty strings in PHP8. If you read relevant the PHP manual parts, you will see that its parameter was restricted:

    • Standard: “The math functions abs(), ceil(), floor() and round() now properly heed the strict_types directive. Previously, they coerced the first argument even in strict type mode.”
    • floor(): “num no longer accepts internal objects which support numeric conversion.”

    Said empty string is exactly what get_post_meta() may well return:

    • “An empty string if a valid but non-existing post ID is passed.”

    (edit: It could, ofc, be that rather than setting 0 for such case, the proper way would be to gracefully show a notice. For that matter, another thread suggest that clearing transients sometimes helps.)

    Our limit is already 512M.

    BTW, aren’t you incidentally already using essentially the same checked way for $max near the same line? You only call ceil() on it after an !empty() check.

    • This reply was modified 4 years, 2 months ago by isarisar.
    • This reply was modified 4 years, 2 months ago by isarisar.
    Plugin Author themifyme

    (@themifyme)

    Hi @isarisar

    Did you check with your hosting provider? They have fixed the admin-ajax.php error? Fixing that should resolve the issue, if that is fixed and the filter is still not working, please let us know.

    Thread Starter isarisar

    (@isarisar)

    I’m sorry, but are you actually reading my replies? The true cause is a faulty floor() call in your code that turns into a full bug in PHP8. I posted the fix!

    Thank you for the fix @isarisar

    It was the same for me and it drove me crazy for days!
    I knew it was related to PHP8 and not to the hosting provider.

    This topic should definitely be put on top list.

    Plugin Author themifyme

    (@themifyme)

    Hi @zestcitron @isarisar

    I asked our developer to check this.

    Plugin Author themifyme

    (@themifyme)

    @zestcitron @isarisar

    Our developer fixed the issue and the fix will be included in the next update.

    Thread Starter isarisar

    (@isarisar)

    Thanks, slightly more wordy fix than the one I used.

    The “PHP Warning: Undefined array key” over accessing non-existent images is still present, though. Could you please show the developer my comment above as to its fix?

    (This will again be escalated to an error in future PHP versions.)

    Plugin Author themifyme

    (@themifyme)

    @isarisar

    I asked our developer to check your comment.

Viewing 15 replies - 1 through 15 (of 15 total)

The topic ‘Add New & Filter Edit broken’ is closed to new replies.