• Resolved aduwow

    (@aduwow)


    Hello,

    I’m using the WP-Appbox plugin and encountered a PHP 8 warning in the admin area:

    Warning: Undefined array key "cacheStore"

    πŸ“ Location

    The issue occurs in the following file:

    wp-appbox/admin/settings-cache-list.php

    πŸ” Root cause

    The warning is caused by accessing $_POST['cacheStore'] without checking if the key exists.

    Examples:

    selected( $_POST['cacheStore'], $storeID );

    and:

    $this->fillData( sanitize_text_field( $_POST['cacheSearch'] ), sanitize_text_field( $_POST['cacheStore'] ) );

    In PHP 8+, this triggers a warning when the form has not been submitted yet.βœ… Suggested fix

    Use isset() or null coalescing to prevent undefined array key warnings:

    selected( $_POST['cacheStore'] ?? '', $storeID );

    and:

    $search = isset($_POST['cacheSearch']) ? sanitize_text_field($_POST['cacheSearch']) : '';
    $store  = isset($_POST['cacheStore']) ? sanitize_text_field($_POST['cacheStore']) : '';
    
    $this->fillData($search, $store);

    ⚠️ Additional issue

    There is also a syntax issue in the same file:

    else( false );

    This should be:

    else return false;

    Please consider updating the plugin for PHP 8 compatibility.

    Thanks!

You must be logged in to reply to this topic.