Forum Replies Created

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter rahul78275

    (@rahul78275)

    Hi @bcworkz , Sorry to bother you again. This is my first plugin and i am losing my interest only due to this plugin checker. It took a lot time in the development and finally everything working expected in the plugin but following standard is an obstacle.

    I tried your solution unfortunately, it didn’t worked as expected. It added single quote around the table name, Cause SQL error

    WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ”wp_lsfw_applications’ ORDER BY ID DESC LIMIT 1′ at line 1]

    SELECT * FROM 'wp_lsfw_tablename' ORDER BY ID DESC LIMIT 1

    Please suggest me a solution so that atleast i am able to submit the initial version of my plugin and keep the motivation up.

    Thank you

    • This reply was modified 1 month ago by rahul78275.
    Thread Starter rahul78275

    (@rahul78275)

    Thank you @bcworkz for the detailed explanation. I want my plugin to work with reverse compatibility

    $wpdb->prepare(
    "SELECT t1.id, t1.product_id, t1.scheduled_at, t1.timezone, t1.thumb, t1.created_at, t2.streamid, t2.overlay
    FROM %i t1
    LEFT JOIN %i t2 ON t1.id = t2.streamid
    WHERE t1.status = %d
    ORDER BY t1.id DESC",
    $table_1,
    $table_2,
    $status_value
    )

    $wpdb->prepare("SELECT * FROM {$table_name} ORDER BY id DESC LIMIT 1");

    Can you please help me to fix this query such that it is widely supported across different versions.

    I tried to create two files one for legacy and other for the latest version like this

    private function load_helper() {

    // Load helper class
    global $wp_version;

    if (version_compare($wp_version, '6.2', '>=')) {
    require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-lsfw-helper.php';

    } else {

    // Legacy support
    require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/legacy/class-lsfw-helper.php';
    }

    $this->helper = new LSFW_Helper();
    }

    Plugin checker warnings are bothering me. It takes long time to review the plugin so i want to make it error free so that reviewer pass it soon.

    Thank you one again.

    Thread Starter rahul78275

    (@rahul78275)

    Thank you for the reply @rollybueno

    There are some other queries where I need to sanitize input like below

    $wpdb->prepare(
    "SELECT t1.id, t1.product_id, t1.scheduled_at, t1.timezone, t1.thumb, t1.created_at, t2.streamid, t2.overlay
    FROM %i t1
    LEFT JOIN %i t2 ON t1.id = t2.streamid
    WHERE t1.status = %d
    ORDER BY t1.id DESC",
    $table_1,
    $table_2,
    $status_value
    )

    Table name i am always using from constant file.
    If i use query like this

    $wpdb->prepare("SELECT * FROM {$table_name} ORDER BY id DESC LIMIT 1");

    It always throw error in “plugin checker”.

    So you mean, I can safely ignore this right @rollybueno ?

    Thread Starter rahul78275

    (@rahul78275)

    It is referring both the line of query

    if ($wpdb->get_var( $wpdb->prepare(“SELECT COUNT(*) FROM “.esc_sql($table_overlays).” WHERE streamid = %d”, $streamid) )) {

    $result = $wpdb->query($wpdb->prepare(“INSERT INTO “.esc_sql($table_overlays).” (streamid, overlay) VALUES (%d, %s)”, $streamid, $overlay));

    If you check the error message, It says something about caching

    Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().

    I tried below as per reference link, but still have same error

    $result = $wpdb->insert(esc_sql($table_overlays), array(‘streamid’ => $streamid, ‘overlay’ => $overlay), array(‘%d’, ‘%s’) );

    Also tried with removing esc_sql().
    Thread Starter rahul78275

    (@rahul78275)

    This is a query to save a form data.

    if ($wpdb->get_var( 
    $wpdb->prepare("SELECT COUNT(*) FROM ".esc_sql($table_overlays)." WHERE streamid = %d", $streamid) )
    ) {
    $result = $wpdb->update(
    esc_sql($table_overlays),
    array('overlay' => $overlay),
    array('streamid' => $streamid),
    array('%s'),
    array('%d')
    );
    } else {
    $result = $wpdb->query($wpdb->prepare("INSERT INTO ".esc_sql($table_overlays)." (streamid, overlay) VALUES (%d, %s)", $streamid, $overlay));
    }
    Thread Starter rahul78275

    (@rahul78275)

    Thanks again @thomas Zwirner

    You are great sir. After posting this question I too started using $wpdb.

    This is my first plugin so I am testing everything very carefully so that It should get accepted in first submission.

    I have more more error in plugin check. I know you can help me in this also.

    WARNING :WordPress.DB.DirectDatabaseQuery.DirectQuery
    Message: Use of a direct database call is discouraged.
    Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().

    Should I implement caching OR if we leave caching, will it make any issue in plugin approval ?

    Please share your opinion, Since caching is a good mechanism, but not willing to apply now in this version. I want this plugin to complete ASAP. Now my motivation is getting low slowly.

    Thank you
    Rahul

    Thread Starter rahul78275

    (@rahul78275)

    Thank you @threadi , I got confidence because of you sir.

    If you’re still stuck with a version prior to 8.x, you’ve been asleep for a while and probably won’t be interested in your plugin.

    You understood a developer feeling well. I thought so much as i can think my best.

    However I worked so hard to write a selenium script with wp-cli to test my plugin across several version.

    But when i saw the detailed version list of woocommerce and wordpress in 3 digits (like: 5.8.0). I got frustrated and decided to test the first version of major release (like: 5.8.1, 5.9, 6.0).

    Here is my test result

    woocommerce.7.2.0 (Having problem wp_readonly(), Its not plugin issue).
    wp - 5.8.1

    woocommerce- 7.2.1
    wp - 5.8.1

    woocommerce- 7.2.2
    wp - 5.8.1

    woocommerce- 7.2.3
    wp - 5.8.1

    woocommerce- 7.3.0
    wp - 5.9

    woocommerce- 7.4.0
    wp - 5.9

    woocommerce- 7.5.0
    wp - 5.9

    woocommerce- 7.6.0
    wp - 6.0

    woocommerce- 7.7.0
    wp - 6.0

    woocommerce- 7.8.0
    wp - 6.1

    woocommerce- 7.9.0
    wp - 6.1

    (On Cart page of 8.0.0 having issue of mixed content, cause cart and checkout not working. Plugin is working fine.)
    woocommerce- 8.0.0
    wp - 6.2

    (Breaking after successful order, at bottom of screen, Also woo-commerce issue.)
    woocommerce- 8.0.0
    wp - 6.2

    (After order successful, notice at the bottom, woo-commerce issue may be)
    woocommerce- 8.1.0
    wp - 6.2

    (After order successful, notice at the bottom, woo-commerce issue may be)
    woocommerce- 8.2.0
    wp - 6.2

    woocommerce- 8.3.0
    wp - 6.3

    woocommerce- 8.4.0
    wp - 6.3

    woocommerce- 8.5.0
    wp - 6.3

    woocommerce- 8.6.0
    wp - 6.3

    woocommerce- 8.7.0
    wp - 6.3

    woocommerce- 8.8.0
    wp - 6.4

    woocommerce- 8.9.0
    wp - 6.4

    woocommerce- 9.0.0
    wp - 6.4

    woocommerce- 9.1.0
    wp - 6.4
    Thread Starter rahul78275

    (@rahul78275)

    Thank You @serafinnyc for sharing forum link. I appreciate you.

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