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

equalizedigital / accessibility-checker / 16195932814

10 Jul 2025 01:05PM UTC coverage: 30.705% (-0.02%) from 30.724%
16195932814

push

github

web-flow
Merge pull request #1078 from equalizedigital/release/1.27.0

Backport: Release/1.27.0

13 of 22 new or added lines in 2 files covered. (59.09%)

1690 of 5504 relevant lines covered (30.7%)

1.99 hits per line

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

84.21
/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
/**
12
 * Class that handles admin notices
13
 *
14
 * @since 1.9.0
15
 */
16
class Update_Database {
17

18
        /**
19
         * Class constructor.
20
         */
21
        public function __construct() {
22
        }
28✔
23

24
        /**
25
         * Initialize WordPress hooks
26
         */
27
        public function init_hooks() {
28
                add_action( 'admin_init', [ $this, 'edac_update_database' ], 10 );
2✔
29
        }
30

31
        /**
32
         * Create/Update database
33
         *
34
         * @return void
35
         */
36
        public function edac_update_database() {
37

38
                global $wpdb;
26✔
39
                $table_name   = $wpdb->prefix . 'accessibility_checker';
26✔
40
                $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.
26✔
41
                        $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $table_name ) )
26✔
42
                ) === $table_name;
26✔
43
                $db_version   = get_option( 'edac_db_version' );
26✔
44

45
                // 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.
46
                if ( EDAC_DB_VERSION !== $db_version || ! $table_exists ) {
26✔
47

48
                        // If going from db version of below 1.0.4 then drop the UNIQUE index on `id` column, it
49
                        // is replaced by a PRIMARY KEY that has a PRIMARY index that constrains uniqueness.
50
                        if ( version_compare( $db_version, '1.0.4', '<' ) && $table_exists ) {
4✔
51

52
                                // does the index exist?
NEW
53
                                $index_exists = $wpdb->get_var(        "SHOW INDEX FROM $table_name WHERE Key_name = 'id'"); // phpcs:ignore
×
54
                                // If the index exists, drop it.
NEW
55
                                if ( $index_exists ) {
×
NEW
56
                                        $wpdb->query( "ALTER TABLE $table_name DROP INDEX id" ); // phpcs:ignore
×
57
                                }
58
                        }
59

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

86
                        require_once ABSPATH . 'wp-admin/includes/upgrade.php';
4✔
87
                        dbDelta( $sql );
4✔
88

89
                }
90

91
                // Update database version option.
92
                update_option( 'edac_db_version', sanitize_text_field( EDAC_DB_VERSION ) );
26✔
93
        }
94
}
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