Forum Replies Created

Viewing 15 replies - 1 through 15 (of 96 total)
  • Thread Starter pixtweaks

    (@pixtweaks)

    Hi, I found the issue. One of folder in chain has capital letter and code is probing lowercase. It’s in file /wp-content/plugins/mailoptin/src/connections/NinjaFormsConnect/Connect.php

    $filename = dirname(__FILE__) . "/integrations/$key.php"; //original code
    $filename = dirname(__FILE__) . "/Integrations/$key.php"; // correct with capital "I"

    I don’t understand structure of your plugin but generating classes should probably happened only in cron or when plugin is activated. Thank you!

    Thread Starter pixtweaks

    (@pixtweaks)

    You welcome! BTW here is the test, if you set 0 in ini_set, the total time will be much slower
    https://onlinephp.io/c/bd146

    Thank you for your work!

    Thread Starter pixtweaks

    (@pixtweaks)

    I’ve dived into this issue and I got the root cause. The slow regex is caused by disabled PCRE JIT. Once you change in php.ini pcre.jit=1 or ini_set(‘pcre.jit’,’1′); in wp-config.php, it would be up to 10x faster. For some reasons, shared hostings using Cloudlinux and Litespeed has this setting off by default.
    I tested it in the real world scenario, how much improvement it would bring and the result is: negligible
    A site using translation plugin Translatepress that is heavily using regex shown no sign of improvement in TTFB.
    Now, I’m very grateful that your plugin could detect it and I will everywhere turn this setting on.

    Thread Starter pixtweaks

    (@pixtweaks)

    I debugged the code and it’s last $paragraphed

    $paragraphed = preg_replace('/\n\n(.+?)(?=\n\n|\z)/s', "<p>\\1</p>", $paragraphed);

    This test on my local runs in about 220 µs, but on shared hosting, the same I posted results, is 2ms, 10x slower for some reason. Now, I think having limit you has added is great, but then we don’t have measurement. I suggest split regex test into two, simple and complex, move this problematic into the new test and make less cycles for it so it’s never more tan 2-3 seconds. Thank you!

    Thread Starter pixtweaks

    (@pixtweaks)

    Hi, I’m glad I could help.
    I briefly checked the last update, and yes, I see many other things that I would do differently. And I want to make clear that I’m not calming my way is the best way, only from my experience, this is how I would consider from my today’s experience and knowledge. Points are made by priority, implementing 1 will bring most benefit and so on.

    1. On what hook is the blocking happening? My guess it’s when plugin run first time. Does it work? Yes! Is this most efficient? Nope. If you want to save as much as possible CPU time, you have to make the decision much sooner. Ideally, on .htaccess level, the second best is PHP prepend file, the third best on mu-plugins hook.
    2. SQL queries

    2.1 I’ve seen SQL queries and I’ve seen overuse of the prepare function. Like you use to prepare for PHP function time(). There is zero chance a hacker would inject SQL statement into time(), if that’s possible, PHP has a BIG issue on the hands. The same thing applies to unnecessary escaping of translations with function like esc_html__().

    2.2 SQL queries have ORDER and GROUP. These two are the most expensive together with OFFSET. Reevaluate them, try to find a way to get what you need from DB without using them

    2.3 If a column has just a few words, like wp_advaipbl_logs has log_type and level, use for column ENUMs rather then text. It’s faster for SELECT and occupied less space. You can always add new into the table schema.

    2.4 INDEX, make sure you have an index only on the column that you need for fast query for performing plugin essential functionality – assessing situation for blocking. When it’s for viewing data, cron clean up, reports and non essential functionality, time is not that important. So yes, your query might be a bit slower but it happening few times. But, not needing writing and maintaining indexes when writing could improve performance.

    1. Plugin’s code itself

    3.1 In my opinion, the biggest WP problem related to back-end performance is useless code. People say “more plugins, less speed”. That’s partially true. It’s true when plugins are not written the day that would execute code only they need. Your plugin always required 32 files that occupies 1MB ram in OPcache. That means that on any page, it’s not only essential blocking code is loaded, all menus, everything has to be compiled and in OPcache. File with your class ADVAIPBL_Main has 9018 lines of code. If OPcache is not full, reading the whole file from disk and compile into OPcache is relativelly long process. Now add 20 more plugins doing the same thing, and you get the result of people saying “more plugins, less speed” and attributing this to WP shortfall instead of inappropriately developed plugins. So if you don’t want to be part of that band, you need to separate code branches. For example, Ajax code is required and executed only when YOURS Ajax request is made. Add to your admin-ajax.php?ip-blocker-something and require Ajax code if isset($_GET[’ip-blocker-something’]).

    3.2 Code readiness.
    Long functions, nesting of code, mixing PHP and HTML.
    Classes should separate functionality, you call DB from many parts of the code. What about one class would perform all DB queries? Same for options. Please watch on youtube video “Clean Code – Uncle Bob / Lesson 1”

    3.3 I see in wp_options some has “auto” for autoload. Make sure only those settings has auto or yes that are really needed on every request, the rest should have ‘no’. And then I see as a value an empty array a:0:{}. No need to store default values, make it rather an empty string.

    3.4 I see $_SERVER[‘REQUEST_URI’] 29 times in the code and all has ??’’ or ‘n/a’ Why not just once and reused?

    All right, there is more, but I really don’t have more time now. What I gave you will keep you busy for a while. I hope it will help.

    All the best,
    Jaro

    Thread Starter pixtweaks

    (@pixtweaks)

    Valid link of the screenshot: https://go.screenpal.com/watch/cTjuQGn2NFd

    Thread Starter pixtweaks

    (@pixtweaks)

    Thread Starter pixtweaks

    (@pixtweaks)

    Hi, thank you for the response.
    API call on small blog with now much traffic is not a problem. I develop plugins for high traffic sites where in 5 minutes can come 15K unique users. If you’re a admin of such a site, plugin like yours would never will be on possible security plugin list, I assure you of that. And you see, every major issue starts as something that is not problem on a small site, nobody notices the difference, only when it grows too much, it’s out of control and it’s much harder to deal with it. One more scenario: DDoS attack, imagine 100K unique IP addresses in few minutes, how much data will be in options table with 100K transients. Yes, I know, most server won’t withstand such a traffic, but those who will, would suffer a lot. You’re building a security plugin, you should count on edge cases, because they do happen.
    I still believe that your caching in transient strategy is not effective one. If you need to know right away the country or ASN then you should have locally database of IP spaces like WordFence or others. If you don’t need to have it right way, then store just IP and with cron, or when displaying the data, fetch the API.
    And about SQLite, really it’s ideal for storing data, latency could be 10x shorter than MySQL and you don’t risk blow up the database size. For whitelist/blacklist absolutely ideal solution.
    All the best!

    Jaro

    I think this test is chronically unreliable, should be optional and not as essential part of the score. Maybe @antonaleksandrov would consider it?

    @galbaras Hi, I just tested 2 shared hosting and got very low score, test lasting up to 54 seconds. But on fast VPS it’s 2.5 seconds. It looks like shared hosting has problem with processing Regex. However, I would argue, that it’s a synthetic test, it may not represent real world scenario how regex is used.

    Thread Starter pixtweaks

    (@pixtweaks)

    Hello @amimulihsanmahdi,
    It’s texarea field, but I think I got the reason. It’s probably incompatibility of database or table attributes.
    This query is from $newQuery = $this->bindParams($query, $bindings, true); the same file and previous line where fatal error is triggered.

    insert into wp_fluentform_entry_details (form_id, submission_id, field_name, sub_field_name, field_value) values (3, 819, 'message', '', '🙏')

    When your code tries to insert it fails and there is no record. When I take this code and insert manually, it’s inserted with error and field_value column has ? sign instead of this character.

    Warning: #1366 Incorrect string value: '\xF0\x9F\x99\x8F' for column firstclass3.wp_fluentform_entry_details.field_value at row 1

    To me my version of DB engine doesn’t like those characters in this configuration. First I have detected this error on 10.6.22-MariaDB and on my local 11.4.5-MariaDB is the same.
    Here is CREATE of the table

    CREATE TABLE wp_fluentform_entry_details (
    id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    form_id bigint(20) unsigned DEFAULT NULL,
    submission_id bigint(20) unsigned DEFAULT NULL,
    field_name varchar(255) DEFAULT NULL,
    sub_field_name varchar(255) DEFAULT NULL,
    field_value longtext DEFAULT NULL,
    PRIMARY KEY (id)
    ) ENGINE=InnoDB AUTO_INCREMENT=4824 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci

    Now, digging deeper, I see that on new installation CHARSET is utf8mb4 that supports those characters and problematic query is inserted without an issue. But for some reason, on my site it’s different CHARSET. Maybe legacy settings of your tables or WP version when the table been created?

    I can now convert it, no problem, but I would suggest from your part:
    1. When plugin is activated or updated, checkup for utf8mb4 is triggered and adjusted, or at least show warning to admin.
    2. This is for your developer, please pass the message: Handle gracefully errors and exceptions. There is no reason for your code trigger the FATAL ERROR when such a case occurs. User on the front end should not see system fatal error but an error message.

    Thank you for your plugins and support!

    Thread Starter pixtweaks

    (@pixtweaks)

    All you need to do is:

    file: classes\FrontController.php
    line: 108
    original code: if ( ! is_admin() ) //this hook is for admin panel only
    new code: if ( ! is_admin() || ($_GET['page']??'') !== 'abh_settings' ) //this hook is for admin panel only

    Thank you 🙂

    Thread Starter pixtweaks

    (@pixtweaks)

    Hello Peter,
    replication and solution is very simple. Login into website where this plugin is used, open developer console and in Network put into filter starbox
    Refresh the page and you should see these two requests:
    /wp-content/plugins/starbox/themes/admin/css/menu.min.css?ver=3.5.4
    /wp-content/plugins/starbox/themes/admin/js/menu.min.js?ver=3.5.4

    Here is the issue, unless you’re on page :
    /wp-admin/options-general.php?page=abh_settings

    these two request should not been made, as your plugin doesn’t do anything on given page. So please let know the developer to put condition before enqueue styles and script, or even better, not require PHP files, unless it’s your page=abh_settings or part of website where plugin does its thing.

    Thank you!

    Here is screenshot of dev tools
    https://go.screenpal.com/watch/cT102fnXd13

    • This reply was modified 9 months, 3 weeks ago by pixtweaks.
    Thread Starter pixtweaks

    (@pixtweaks)

    Hi,
    thanks for the reply. How I see it that this table is config table wp_wfConfig so, when the plugin is activated, default settings is inserted, including lastNotificationID so UPDATE will work all the time, presuming there is no DELETE for this row.

    Regards,
    Jaro

    Thread Starter pixtweaks

    (@pixtweaks)

    Thank you @cookieyesteam for pointing me in the right direction. Here is the code that works for me, when performance cookies are allowed it will log the console. It may help somebody else.

    document.addEventListener(‘cookieyes_consent_update’, function (e) {

        if (e.detail && e.detail.accepted.includes(‘performance’)) {

          console.log(‘Performance allowed for the first time’);

        }

    });

    document.addEventListener(‘cookieyes_banner_load’, function (e){

        if (e.detail && e.detail.categories && e.detail.categories.performance === true) {

            console.log(‘Performance allowed repeated load’);

        }

    });

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