Quick Links Manager

Duplicate Database Entries - Quick Links Manager

Duplicate Database Entries

by mhsuffolk » Sun Jun 21, 2026 8:41 am

1.1.0.6 V2.1
Getting this with every click in admin
Warning: Constant MODULE_ADMIN_QUICK_LINKS_JSON already defined in D:\Laragon\www\admin\includes\application_top.php on line 62

Warning: Constant MODULE_ADMIN_QUICK_LINKS_EXCLUDE already defined in D:\Laragon\www\admin\includes\application_top.php on line 62

Also every click produces a new line in the configuration table
Table.JPG
User avatar
mhsuffolk
Contributor
Posts: 199
Joined: Sat Oct 26, 2019 9:13 am
Phoenix Version: v1.1.0.6
Contact:

Re: Duplicate Database Entries

by Mort_Lemur » Sun Jun 21, 2026 9:27 am

Hi,
Try this and let me know if it solves the problem:
Run this sql to clean the database:

Code: Select all

DELETE FROM configuration WHERE configuration_key = 'MODULE_ADMIN_QUICK_LINKS_JSON' AND configuration_id NOT IN (SELECT MIN(configuration_id) FROM (SELECT * FROM configuration) as temp WHERE configuration_key = 'MODULE_ADMIN_QUICK_LINKS_JSON');

DELETE FROM configuration WHERE configuration_key = 'MODULE_ADMIN_QUICK_LINKS_EXCLUDE' AND configuration_id NOT IN (SELECT MIN(configuration_id) FROM (SELECT * FROM configuration) as temp WHERE configuration_key = 'MODULE_ADMIN_QUICK_LINKS_EXCLUDE');
Then replace the entire contents of quicklinksmenu.php with this code:

Code: Select all

<?php
declare(strict_types=1);

class hook_admin_siteWide_quicklinksmenu {

    public function listen_injectSiteEnd(): string {
        global $db;

        // 1. Safe "Self-Healing" check (Only runs if key doesn't exist)
        $check = $db->query("SELECT configuration_id FROM configuration WHERE configuration_key = 'MODULE_ADMIN_QUICK_LINKS_JSON'");
        if ($check->num_rows === 0) {
            $db->query("INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) VALUES ('Quick Links JSON', 'MODULE_ADMIN_QUICK_LINKS_JSON', '[]', 'JSON data for Quick Links', '6', '1', NOW())");
        }
        $check2 = $db->query("SELECT configuration_id FROM configuration WHERE configuration_key = 'MODULE_ADMIN_QUICK_LINKS_EXCLUDE'");
        if ($check2->num_rows === 0) {
            $db->query("INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) VALUES ('Excluded Pages', 'MODULE_ADMIN_QUICK_LINKS_EXCLUDE', 'invoice.php\npackingslip.php', 'Filenames to exclude', '6', '2', NOW())");
        }

        // 2. Fetch Exclusion List
        $ex_query = $db->query("SELECT configuration_value FROM configuration WHERE configuration_key = 'MODULE_ADMIN_QUICK_LINKS_EXCLUDE'");
        $ex_row = $ex_query->fetch_assoc();
        $excluded_files = array_map('trim', explode("\n", $ex_row['configuration_value'] ?? ''));
        
        $current_file = basename($_SERVER['PHP_SELF']);
        $is_manage = (isset($_GET['page']) && $_GET['page'] === 'quick_links_manage');

        if (in_array($current_file, $excluded_files) || $is_manage) {
            return ''; 
        }

        // 3. Fetch and render links
        $query = $db->query("SELECT configuration_value FROM configuration WHERE configuration_key = 'MODULE_ADMIN_QUICK_LINKS_JSON'");
        $result = $query->fetch_assoc();
        $buttons = json_decode((string)($result['configuration_value'] ?? '[]'), true);

        if (empty($buttons) || !is_array($buttons)) return '';

        $html = '<div id="quicklinks-container" class="container-fluid mb-3 w-100 clearfix">';
        $html .= '<div class="d-flex justify-content-center flex-wrap">';
        
        foreach ($buttons as $btn) {
            $icon = !empty($btn['icon']) ? htmlspecialchars((string)$btn['icon']) : 'fa-link';
            $label = htmlspecialchars((string)$btn['label']);
            $url = htmlspecialchars((string)$btn['url']);
            $color = !empty($btn['color']) ? htmlspecialchars((string)$btn['color']) : '#6c757d';
            $style = ' style="border-color: ' . $color . ' !important; color: ' . $color . ' !important;"';

            $html .= '<a href="'.$url.'" class="btn btn-sm btn-outline-secondary mx-1"'.$style.'>';
            $html .= '<i class="fas '.$icon.' mr-1"></i>'.$label;
            $html .= '</a>';
        }
        
        $html .= '</div></div>';

        $html .= '<script>
            document.addEventListener("DOMContentLoaded", function() {
                var container = document.getElementById("quicklinks-container");
                if (container) {
                    var firstRow = document.querySelector(".content-body .row, main .row, .container-fluid .row, .row");
                    if (firstRow) { firstRow.parentNode.insertBefore(container, firstRow); }
                    else { document.body.prepend(container); }
                }
            });
        </script>';

        return $html;
    }
}
User avatar
Mort_Lemur
Builder
Posts: 62
Joined: Tue Jun 02, 2026 6:12 pm
Phoenix Version: v1.1.0.6
Contact:

Re: Duplicate Database Entries

by mhsuffolk » Sun Jun 21, 2026 9:59 am

Yes, that has cured it thank you. There are now only 2 lines in the config table.
User avatar
mhsuffolk
Contributor
Posts: 199
Joined: Sat Oct 26, 2019 9:13 am
Phoenix Version: v1.1.0.6
Contact: