• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

equalizedigital / accessibility-checker / 22024231170

14 Feb 2026 09:04PM UTC coverage: 57.263%. First build
22024231170

Pull #1413

github

web-flow
Merge c07f857fb into 1cbcfbf9b
Pull Request #1413: Fix loopback helper warning on DNS AAAA failures

27 of 81 new or added lines in 24 files covered. (33.33%)

4147 of 7242 relevant lines covered (57.26%)

3.47 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.3
/admin/class-update-database.php
1
<?php
2
/**
3
 * Class file for updating the database.
4
 *
5
 * @package Accessibility_Checker
6
 * @since 1.9.0
7
 */
8

9
namespace EDAC\Admin;
10

11
if ( ! defined( 'ABSPATH' ) ) {
2✔
NEW
12
        exit;
×
13
}
14

15
/**
16
 * Class that handles admin notices
17
 *
18
 * @since 1.9.0
19
 */
20
class Update_Database {
21

22
        /**
23
         * Class constructor.
24
         */
25
        public function __construct() {
26
        }
48✔
27

28
        /**
29
         * Initialize WordPress hooks
30
         */
31
        public function init_hooks() {
32
                add_action( 'admin_init', [ $this, 'edac_update_database' ], 10 );
2✔
33
        }
34

35
        /**
36
         * Create/Update database
37
         *
38
         * @return void
39
         */
40
        public function edac_update_database() {
41

42
                global $wpdb;
46✔
43
                $table_name   = $wpdb->prefix . 'accessibility_checker';
46✔
44
                $table_exists = $wpdb->get_var( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Safe variable used for table name, caching not required for one time operation.
46✔
45
                        $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $table_name ) )
46✔
46
                ) === $table_name;
46✔
47
                $db_version   = get_option( 'edac_db_version' );
46✔
48

49
                // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Prepare above, Safe variable used for table name, caching not required for one time operation.
50
                if ( EDAC_DB_VERSION !== $db_version || ! $table_exists ) {
46✔
51

52
                        $charset_collate = $wpdb->get_charset_collate();
4✔
53
                        $sql             = "CREATE TABLE $table_name (
4✔
54
                                id bigint(20) NOT NULL AUTO_INCREMENT,
55
                                postid bigint(20) NOT NULL,
56
                                siteid text NOT NULL,
57
                                type text NOT NULL,
58
                                landmark varchar(20) NULL,
59
                                landmark_selector text NULL,
60
                                selector text NULL,
61
                                ancestry text NULL,
62
                                xpath text NULL,
63
                                rule text NOT NULL,
64
                                ruletype text NOT NULL,
65
                                object mediumtext NOT NULL,
66
                                recordcheck mediumint(9) NOT NULL,
67
                                created timestamp NOT NULL default CURRENT_TIMESTAMP,
68
                                user bigint(20) NOT NULL,
69
                                ignre mediumint(9) NOT NULL,
70
                                ignre_global mediumint(9) NOT NULL,
71
                                ignre_user bigint(20) NULL,
72
                                ignre_date timestamp NULL,
73
                                ignre_comment mediumtext NULL,
74
                                PRIMARY KEY (id),
75
                                KEY postid_index (postid)
76
                        ) $charset_collate;";
4✔
77

78
                        require_once ABSPATH . 'wp-admin/includes/upgrade.php';
4✔
79
                        dbDelta( $sql );
4✔
80

81
                        // Run migration for selector-based unique identifiers if upgrading from older versions.
82
                        if ( version_compare( $db_version, '1.0.5', '<' ) ) {
4✔
83
                                $this->migrate_to_selector_based_unique_id();
4✔
84
                        }       
85
                }
86

87
                // Update database version option.
88
                update_option( 'edac_db_version', sanitize_text_field( EDAC_DB_VERSION ) );
46✔
89
        }
90

91
        /**
92
         * Migrate existing records to use selector-based unique identifiers.
93
         *
94
         * This migration handles records that were created before the selector field
95
         * was used as the unique identifier. Records with NULL selectors will have
96
         * a fallback identifier generated based on their ID to ensure uniqueness.
97
         *
98
         * @since 1.0.5
99
         * @return void
100
         */
101
        private function migrate_to_selector_based_unique_id() {
102
                global $wpdb;
4✔
103
                $table_name = $wpdb->prefix . 'accessibility_checker';
4✔
104

105
                // Find records with NULL or empty selectors and update them with a fallback value.
106
                // Using the record ID ensures each record has a unique selector for backward compatibility.
107
                // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- One-time migration query.
108
                $wpdb->query(
4✔
109
                        $wpdb->prepare(
4✔
110
                                "UPDATE %i SET selector = CONCAT('legacy-id-', id) WHERE selector IS NULL OR selector = ''",
4✔
111
                                $table_name
4✔
112
                        )
4✔
113
                );
4✔
114
        }
115
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc