PluginProbe
Booking Calendar / 11.8.3
Booking Calendar v11.8.3
11.8.3 11.8.2 11.8.1 11.8 11.7 11.6.1 11.6 11.5 11.4.3 11.4.2 11.4.1 11.4 11.3 11.2.1 11.2 11.1 11.0 10.15.7 10.15.6 10.1.3 10.10 10.10.1 10.10.2 10.11 10.11.2 All 203 releases
← All changes | includes/_functions/is_table_exist.php +45 -51 10.11.211.8.3 View file →
@@ -1,4 +1,4 @@
1 1 <?php
2 2 /**
3 3 * @version 1.0
4 4 * @package Booking Calendar
@@ -38,9 +38,9 @@
38 38 }
39 39
40 40 if ( 0 ) {
41 41 $sql_check_table = $wpdb->prepare( "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE (TABLE_SCHEMA = '{$wpdb->dbname}') AND (TABLE_NAME = %s);", $tablename );
42 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
42 + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter
43 43 $res = $wpdb->get_results( $sql_check_table );
44 44
45 45 return count( $res );
46 46
@@ -46,9 +46,9 @@
46 46
47 47 } else {
48 48
49 49 $sql_check_table = $wpdb->prepare( "SHOW TABLES LIKE %s", $tablename ); //FixIn: 5.4.3
50 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
50 + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter
51 51 $res = $wpdb->get_results( $sql_check_table );
52 52
53 53 return count( $res );
54 54 }
@@ -55,45 +55,33 @@
55 55
56 56 }
57 57
58 58
59 -// FixIn: 10.0.0.1.
60 -/**
61 - * Check if we are in playground.wordpress.net , where used 'sqlite' DB
62 - *
63 - * @return bool
64 - */
65 -function wpbc_is_this_wp_playground_db(){
66 59
67 - return false;
68 60
69 - if (
70 - ( ( function_exists( 'sqlite_open' ) ) || ( class_exists( 'SQLite3' ) ) )
71 - && ( ! class_exists( 'wpdev_bk_personal' ) )
72 - ){
73 - return true;
74 - } else {
75 - return false;
76 - }
77 -}
61 +/**
62 + * Check whether a field exists in a database table.
63 + *
64 + * Missing tables return zero without issuing a column query. This keeps
65 + * activation schema checks quiet while an owning edition is not installed yet.
66 + *
67 + * @param string $tablename Table name or Booking Calendar table suffix.
68 + * @param string $fieldname Field name.
69 + *
70 + * @return int One when the field exists; otherwise zero.
71 + * @global wpdb $wpdb WordPress database abstraction object.
72 + */
73 +function wpbc_is_field_in_table_exists( $tablename, $fieldname ) {
74 +
75 + global $wpdb;
76 +
77 + // Schema probes against a missing table emit a visible WordPress database error.
78 + // Activation callers treat a missing table and a missing field identically, so
79 + // fail closed before issuing SHOW COLUMNS.
80 + if ( 0 === wpbc_is_table_exists( $tablename ) ) {
81 + return 0;
82 + }
78 83
79 -
80 -/**
81 - * Check if table exist
82 - *
83 - * @global $wpdb
84 - * @param string $tablename
85 - * @param $fieldname
86 - * @return 0|1
87 - */
88 -function wpbc_is_field_in_table_exists( $tablename, $fieldname ) {
89 -
90 - if ( wpbc_is_this_wp_playground_db() ) {
91 - return 1; // Probably we are in playground.wordpress.net --> So then all such fields already was created // FixIn: 10.0.0.1.
92 - }
93 -
94 - global $wpdb;
95 -
96 84 if (
97 85 ( ( ! empty( $wpdb->prefix ) ) && ( strpos( $tablename, $wpdb->prefix ) === false ) )
98 86 || ( '_' == $wpdb->prefix ) // FixIn: 8.7.3.16.
99 87 ) {
@@ -102,9 +90,9 @@
102 90
103 91 if ( 0 ) {
104 92
105 93 $sql_check_table = "SELECT * FROM INFORMATION_SCHEMA.COLUMNS where TABLE_NAME='{$tablename}' AND TABLE_SCHEMA='{$wpdb->dbname}' ";
106 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
94 + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter
107 95 $res = $wpdb->get_results( $sql_check_table );
108 96
109 97 foreach ( $res as $fld ) {
110 98 if ( $fieldname === $fld->COLUMN_NAME ) {
@@ -114,9 +102,9 @@
114 102
115 103 } else {
116 104
117 105 $sql_check_table = "SHOW COLUMNS FROM {$tablename}";
118 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
106 + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter
119 107 $res = $wpdb->get_results( $sql_check_table );
120 108
121 109 foreach ( $res as $fld ) {
122 110 if ( $fld->Field == $fieldname ) {
@@ -128,25 +116,31 @@
128 116 return 0;
129 117 }
130 118
131 119
132 -/**
133 - * Check if index exist
134 - *
135 - * @param string $tablename
136 - * @param $fieldindex
137 - *
138 - * @return 0|1
139 - * @global $wpdb
140 - */
141 -function wpbc_is_index_in_table_exists( $tablename, $fieldindex ) {
142 - global $wpdb;
143 - if ( ( ! empty( $wpdb->prefix ) ) && ( strpos( $tablename, $wpdb->prefix ) === false ) ) {
120 +/**
121 + * Check whether an index exists in a database table.
122 + *
123 + * Missing tables return zero without issuing an index query.
124 + *
125 + * @param string $tablename Table name or Booking Calendar table suffix.
126 + * @param string $fieldindex Index name.
127 + *
128 + * @return int One when the index exists; otherwise zero.
129 + * @global wpdb $wpdb WordPress database abstraction object.
130 + */
131 +function wpbc_is_index_in_table_exists( $tablename, $fieldindex ) {
132 + global $wpdb;
133 +
134 + if ( 0 === wpbc_is_table_exists( $tablename ) ) {
135 + return 0;
136 + }
137 + if ( ( ! empty( $wpdb->prefix ) ) && ( strpos( $tablename, $wpdb->prefix ) === false ) ) {
144 138 $tablename = $wpdb->prefix . $tablename;
145 139 }
146 140 /* phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, WordPress.DB.PreparedSQL.InterpolatedNotPrepared */
147 141 $sql_check_table = $wpdb->prepare( "SHOW INDEX FROM {$tablename} WHERE Key_name = %s", $fieldindex );
148 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
142 + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter
149 143 $res = $wpdb->get_results( $sql_check_table );
150 144 if ( count( $res ) > 0 ) {
151 145 return 1;
152 146 } else {