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 +40 -24 11.6.111.8.3 View file →
@@ -1,4 +1,4 @@
1 1 <?php
2 2 /**
3 3 * @version 1.0
4 4 * @package Booking Calendar
@@ -57,21 +57,31 @@
57 57
58 58
59 59
60 60
61 -/**
62 - * Check if table exist
63 - *
64 - * @global $wpdb
65 - * @param string $tablename
66 - * @param $fieldname
67 - * @return 0|1
68 - */
69 -function wpbc_is_field_in_table_exists( $tablename, $fieldname ) {
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 + }
70 83
71 -
72 - global $wpdb;
73 -
74 84 if (
75 85 ( ( ! empty( $wpdb->prefix ) ) && ( strpos( $tablename, $wpdb->prefix ) === false ) )
76 86 || ( '_' == $wpdb->prefix ) // FixIn: 8.7.3.16.
77 87 ) {
@@ -106,20 +116,26 @@
106 116 return 0;
107 117 }
108 118
109 119
110 -/**
111 - * Check if index exist
112 - *
113 - * @param string $tablename
114 - * @param $fieldindex
115 - *
116 - * @return 0|1
117 - * @global $wpdb
118 - */
119 -function wpbc_is_index_in_table_exists( $tablename, $fieldindex ) {
120 - global $wpdb;
121 - 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 ) ) {
122 138 $tablename = $wpdb->prefix . $tablename;
123 139 }
124 140 /* phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, WordPress.DB.PreparedSQL.InterpolatedNotPrepared */
125 141 $sql_check_table = $wpdb->prepare( "SHOW INDEX FROM {$tablename} WHERE Key_name = %s", $fieldindex );