Changeset 2888447
- Timestamp:
- 03/28/2023 01:56:20 PM (3 years ago)
- Location:
- blockprotocol/trunk
- Files:
-
- 8 edited
-
block-protocol.php (modified) (3 diffs)
-
changelog.txt (modified) (1 diff)
-
readme.txt (modified) (4 diffs)
-
server/block-api-endpoints.php (modified) (7 diffs)
-
server/block-db-table.php (modified) (4 diffs)
-
vendor/composer/autoload_psr4.php (modified) (1 diff)
-
vendor/composer/autoload_static.php (modified) (2 diffs)
-
vendor/composer/installed.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
blockprotocol/trunk/block-protocol.php
r2886540 r2888447 2 2 /** 3 3 * @package blockprotocol 4 * @version 0.0. 54 * @version 0.0.6 5 5 */ 6 6 /* … … 10 10 Author: Block Protocol 11 11 Author URI: https://blockprotocol.org/?utm_medium=organic&utm_source=wordpress_plugin-directory_blockprotocol-plugin_author-name 12 Version: 0.0. 512 Version: 0.0.6 13 13 Requires at least: 5.6.0 14 14 Tested up to: 6.1.1 … … 17 17 */ 18 18 19 const BLOCK_PROTOCOL_PLUGIN_VERSION = "0.0. 5";19 const BLOCK_PROTOCOL_PLUGIN_VERSION = "0.0.6"; 20 20 21 21 if (is_readable(__DIR__ . '/vendor/autoload.php')) { -
blockprotocol/trunk/changelog.txt
r2886540 r2888447 1 1 == Changelog == 2 3 = 0.0.6 = 4 * Support older versions of MySQL (Minimum version is now 5.7.8 down from 8.0) 2 5 3 6 = 0.0.5 = -
blockprotocol/trunk/readme.txt
r2886540 r2888447 6 6 Tested up to: 6.1.1 7 7 Requires PHP: 7.4 8 Stable tag: 0.0. 58 Stable tag: 0.0.6 9 9 License: AGPL-3.0 10 10 License URI: https://www.gnu.org/licenses/agpl-3.0.en.html … … 37 37 **5.** If you want to add your own block to the plugin, visit https://blockprotocol.org/docs/developing-blocks 38 38 39 Note that you must be using at least MySQL 8. To check please navigate to `Admin -> Tools -> Site Health -> Info -> Database`.40 The previous versions of MySQL (5.6 and 5.7)respectively reach(ed) end of life in February 2021 and October 2023.41 You should upgrade to MySQL 8 now to continue to receive security updates, as well as to use the Block Protocolwithin WordPress.39 Note that you must be using at least MySQL 5.7.8. To check please navigate to `Admin -> Tools -> Site Health -> Info -> Database`. 40 MySQL 5.6 and 5.7 respectively reach(ed) end of life in February 2021 and October 2023. 41 You should upgrade to MySQL 8 now to continue to receive security updates, as well as to get the best Block Protocol experience within WordPress. 42 42 43 43 When you install or use the _Block Protocol for WordPress_ plugin, we don’t send any data to any third-party analytics services. … … 85 85 <!-- Only the latest release's entry should appear here – the full log should be in changelog.txt --> 86 86 87 = 0.0. 5=88 * Handle blocks being inside an iFrame in editor view (fixes incompatibility with Gutenberg plugin)87 = 0.0.6 = 88 * Support older versions of MySQL (Minimum version is now 5.7.8 down from 8.0) 89 89 90 90 == Upgrade Notice == … … 92 92 <!-- Upgrade notices describe the reason a user should upgrade. No more than 300 characters. --> 93 93 94 = 0.0. 5=95 Upgrade for compatibility with the Gutenberg plugin94 = 0.0.6 = 95 Upgrade for support for older versions of MySQL (new minimum 5.7.8) -
blockprotocol/trunk/server/block-api-endpoints.php
r2882010 r2888447 21 21 } 22 22 23 function get_block_protocol_subgraph( 24 string $base_where_term, 25 int $has_left_incoming_depth, 26 int $has_right_incoming_depth, 27 int $has_left_outgoing_depth, 28 int $has_right_outgoing_depth 29 ) 30 { 31 global $wpdb; 32 33 $table = get_block_protocol_table_name(); 34 35 $selection = " 23 function block_protocol_entity_selection() 24 { 25 return " 36 26 entity_id, 37 27 entity_type_id, … … 45 35 updated_by_id, 46 36 updated_at"; 37 38 } 39 40 /** 41 * Natively traverse a subgraph using a base where term. 42 * This functions is meant to be as compatible as possible with various MySQL/MariaDB versions 43 */ 44 function block_protocol_native_subgraph_query( 45 string $base_where_term, 46 int $has_left_incoming_depth, 47 int $has_right_incoming_depth, 48 int $has_left_outgoing_depth, 49 int $has_right_outgoing_depth 50 ) { 51 global $wpdb; 52 53 $table = get_block_protocol_table_name(); 54 55 $subgraph = []; 56 $queue = []; 57 58 // Initial query using the base where term 59 $selection = block_protocol_entity_selection(); 60 $sql = $wpdb->prepare(" 61 SELECT 62 " . $selection . ", 63 0 as has_left_incoming_depth, 64 0 as has_right_incoming_depth, 65 0 as has_left_outgoing_depth, 66 0 as has_right_outgoing_depth 67 FROM {$table} 68 " . $base_where_term 69 ); 70 71 // Initialize the queue with the starting nodes 72 $queue = $wpdb->get_results($sql, ARRAY_A); 73 74 $visited = []; 75 76 // Loop while the queue is not empty 77 while (!empty($queue)) { 78 // Dequeue the next node 79 $node = array_shift($queue); 80 81 // Skip nodes that have already been visited 82 if ($visited[$node['entity_id']] ?? false) { 83 continue; 84 } 85 86 $visited[$node['entity_id']] = true; 87 88 // ensure that the depths are all ints 89 $node['has_left_incoming_depth'] = (int) $node['has_left_incoming_depth']; 90 $node['has_right_incoming_depth'] = (int) $node['has_right_incoming_depth']; 91 $node['has_left_outgoing_depth'] = (int) $node['has_left_outgoing_depth']; 92 $node['has_right_outgoing_depth'] = (int) $node['has_right_outgoing_depth']; 93 94 // Add the node to the result list 95 $subgraph[] = $node; 96 97 $next_nodes = []; 98 99 // Add nodes connected by incoming has_left links 100 if ($node['has_left_incoming_depth'] < $has_left_incoming_depth) { 101 $sql = $wpdb->prepare( 102 "SELECT 103 " . $selection . ", 104 %d + 1 as has_left_incoming_depth, 105 %d as has_right_incoming_depth, 106 %d as has_left_outgoing_depth, 107 %d as has_right_outgoing_depth 108 FROM {$table} 109 WHERE left_entity_id = %d 110 ", 111 $node['has_left_incoming_depth'], 112 $node['has_right_incoming_depth'], 113 $node["has_left_outgoing_depth"], 114 $node["has_right_outgoing_depth"], 115 $node['entity_id'] 116 ); 117 118 $next_nodes = array_merge($next_nodes, $wpdb->get_results($sql, ARRAY_A)); 119 } 120 121 // Add nodes connected by incoming has_right links 122 if ($node['has_right_incoming_depth'] < $has_right_incoming_depth) { 123 $sql = $wpdb->prepare( 124 "SELECT 125 " . $selection . ", 126 %d as has_left_incoming_depth, 127 %d + 1 as has_right_incoming_depth, 128 %d as has_left_outgoing_depth, 129 %d as has_right_outgoing_depth 130 FROM {$table} 131 WHERE right_entity_id = %d 132 ", 133 $node['has_left_incoming_depth'], 134 $node['has_right_incoming_depth'], 135 $node["has_left_outgoing_depth"], 136 $node["has_right_outgoing_depth"], 137 $node['entity_id'] 138 ); 139 140 $next_nodes = array_merge($next_nodes, $wpdb->get_results($sql, ARRAY_A)); 141 } 142 143 // Add nodes connected by outgoing has_left links 144 if ($node['has_left_outgoing_depth'] < $has_left_outgoing_depth) { 145 $sql = $wpdb->prepare( 146 "SELECT 147 " . $selection . ", 148 %d as has_left_incoming_depth, 149 %d as has_right_incoming_depth, 150 %d + 1 as has_left_outgoing_depth, 151 %d as has_right_outgoing_depth 152 FROM {$table} 153 WHERE entity_id = %d 154 ", 155 $node['has_left_incoming_depth'], 156 $node['has_right_incoming_depth'], 157 $node["has_left_outgoing_depth"], 158 $node["has_right_outgoing_depth"], 159 $node['left_entity_id'] 160 ); 161 162 $next_nodes = array_merge($next_nodes, $wpdb->get_results($sql, ARRAY_A)); 163 } 164 165 // Add nodes connected by outgoing has_right links 166 if ($node['has_right_outgoing_depth'] < $has_right_outgoing_depth) { 167 $sql = $wpdb->prepare( 168 "SELECT 169 " . $selection . ", 170 %d as has_left_incoming_depth, 171 %d as has_right_incoming_depth, 172 %d as has_left_outgoing_depth, 173 %d + 1 as has_right_outgoing_depth 174 FROM {$table} 175 WHERE entity_id = %d 176 ", 177 $node['has_left_incoming_depth'], 178 $node['has_right_incoming_depth'], 179 $node["has_left_outgoing_depth"], 180 $node["has_right_outgoing_depth"], 181 $node['right_entity_id'] 182 ); 183 184 $next_nodes = array_merge($next_nodes, $wpdb->get_results($sql, ARRAY_A)); 185 } 186 187 // Add the next nodes to the queue 188 foreach ($next_nodes as $next_node) { 189 $entity_id = $next_node['entity_id']; 190 191 if (!($visited[$entity_id] ?? false)) { 192 $queue[] = $next_node; 193 } 194 } 195 } 196 197 foreach($subgraph as &$element) { 198 unset($element["has_left_incoming_depth"]); 199 unset($element["has_right_incoming_depth"]); 200 unset($element["has_left_outgoing_depth"]); 201 unset($element["has_right_outgoing_depth"]); 202 } 203 204 return $subgraph; 205 } 206 207 208 /** 209 * Traverse a subgraph using Recursive CTEs in the DB. 210 * This functions is likely unsupported by older versions of the DB. 211 */ 212 function block_protocol_db_subgraph_query( 213 string $base_where_term, 214 int $has_left_incoming_depth, 215 int $has_right_incoming_depth, 216 int $has_left_outgoing_depth, 217 int $has_right_outgoing_depth 218 ) 219 { 220 global $wpdb; 221 222 $table = get_block_protocol_table_name(); 223 224 $selection = block_protocol_entity_selection(); 47 225 48 226 $sql = $wpdb->prepare( … … 78 256 has_left_outgoing_depth, 79 257 has_right_outgoing_depth 80 FROM {$table} e2 81 JOIN linked_entities 258 FROM {$table} e2 259 JOIN linked_entities 82 260 ON e2.left_entity_id = linked_entities.entity_id 83 261 WHERE has_left_incoming_depth < %d … … 102 280 has_left_outgoing_depth, 103 281 has_right_outgoing_depth 104 FROM {$table} e2 105 JOIN linked_entities 282 FROM {$table} e2 283 JOIN linked_entities 106 284 ON e2.right_entity_id = linked_entities.entity_id 107 285 WHERE has_right_incoming_depth < %d … … 126 304 has_left_outgoing_depth +1, 127 305 has_right_outgoing_depth 128 FROM {$table} e2 129 JOIN linked_entities 306 FROM {$table} e2 307 JOIN linked_entities 130 308 ON e2.entity_id = linked_entities.left_entity_id 131 309 WHERE has_left_outgoing_depth < %d … … 150 328 has_left_outgoing_depth, 151 329 has_right_outgoing_depth + 1 152 FROM {$table} e2 153 JOIN linked_entities 330 FROM {$table} e2 331 JOIN linked_entities 154 332 ON e2.entity_id = linked_entities.right_entity_id 155 333 WHERE has_right_outgoing_depth < %d … … 166 344 167 345 $subgraph = $wpdb->get_results($sql, ARRAY_A); 346 347 return $subgraph; 348 } 349 350 function get_block_protocol_subgraph( 351 string $base_where_term, 352 int $has_left_incoming_depth, 353 int $has_right_incoming_depth, 354 int $has_left_outgoing_depth, 355 int $has_right_outgoing_depth 356 ) 357 { 358 global $wpdb; 359 // See https://dev.mysql.com/doc/refman/8.0/en/mysql-nutshell.html 360 $mysql_recursive_cte_version = "8.0"; 361 // See https://mariadb.com/kb/en/mariadb-1022-release-notes/#notable-changes 362 $mariadb_recursive_cte_version = "10.2.2"; 363 364 // Dynamically choose how to execute the query based on the database version 365 $action = 366 block_protocol_database_at_version( 367 $mysql_recursive_cte_version, 368 $mariadb_recursive_cte_version 369 ) 370 ? "block_protocol_db_subgraph_query" 371 : "block_protocol_native_subgraph_query"; 372 373 $subgraph = ($action)( 374 $base_where_term, 375 $has_left_incoming_depth, 376 $has_right_incoming_depth, 377 $has_left_outgoing_depth, 378 $has_right_outgoing_depth, 379 ); 168 380 169 381 block_protocol_maybe_capture_error($wpdb->last_error); -
blockprotocol/trunk/server/block-db-table.php
r2882010 r2888447 1 1 <?php 2 2 3 const BLOCK_PROTOCOL_MINIMUM_MYSQL_VERSION = " 8.0.0";3 const BLOCK_PROTOCOL_MINIMUM_MYSQL_VERSION = "5.7.8"; 4 4 const BLOCK_PROTOCOL_MINIMUM_MARIADB_VERSION = "10.2.7"; 5 5 6 function block_protocol_ is_database_supported()6 function block_protocol_database_at_version(string $mysql_version, string $mariadb_version) 7 7 { 8 8 9 global $wpdb; 9 10 … … 13 14 if (strpos($db_server_info, 'MariaDB') != false) { 14 15 // site is using MariaDB 15 return $db_version >= BLOCK_PROTOCOL_MINIMUM_MARIADB_VERSION;16 return strnatcmp($db_version, $mariadb_version) > 0; 16 17 } else { 17 18 // site is using MySQL 18 return $db_version >= BLOCK_PROTOCOL_MINIMUM_MYSQL_VERSION;19 return strnatcmp($db_version, $mysql_version) > 0; 19 20 } 21 } 22 23 function block_protocol_is_database_supported() 24 { 25 return block_protocol_database_at_version( 26 BLOCK_PROTOCOL_MINIMUM_MYSQL_VERSION, 27 BLOCK_PROTOCOL_MINIMUM_MARIADB_VERSION 28 ); 20 29 } 21 30 … … 55 64 } 56 65 66 function block_protocol_set_migration_version_to(int $migration_version) 67 { 68 global $wpdb; 69 70 if (!$wpdb->last_error){ 71 update_site_option('block_protocol_db_migration_version', $migration_version); 72 } 73 } 74 57 75 function block_protocol_migrate() 58 76 { … … 66 84 if ($saved_version < 2) { 67 85 block_protocol_migration_1(); 68 update_site_option('block_protocol_db_migration_version',2);86 block_protocol_set_migration_version_to(2); 69 87 } 70 88 -
blockprotocol/trunk/vendor/composer/autoload_psr4.php
r2886540 r2888447 15 15 'Sentry\\' => array($vendorDir . '/sentry/sentry/src'), 16 16 'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'), 17 'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http- message/src', $vendorDir . '/psr/http-factory/src'),17 'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-factory/src', $vendorDir . '/psr/http-message/src'), 18 18 'Psr\\Http\\Client\\' => array($vendorDir . '/psr/http-client/src'), 19 19 'Psr\\Container\\' => array($vendorDir . '/psr/container/src'), 20 20 'Jean85\\' => array($vendorDir . '/jean85/pretty-package-versions/src'), 21 21 'Http\\Promise\\' => array($vendorDir . '/php-http/promise/src'), 22 'Http\\Message\\' => array($vendorDir . '/php-http/message -factory/src', $vendorDir . '/php-http/message/src'),22 'Http\\Message\\' => array($vendorDir . '/php-http/message/src', $vendorDir . '/php-http/message-factory/src'), 23 23 'Http\\Factory\\Guzzle\\' => array($vendorDir . '/http-interop/http-factory-guzzle/src'), 24 24 'Http\\Discovery\\' => array($vendorDir . '/php-http/discovery/src'), -
blockprotocol/trunk/vendor/composer/autoload_static.php
r2886540 r2888447 95 95 'Psr\\Http\\Message\\' => 96 96 array ( 97 0 => __DIR__ . '/..' . '/psr/http- message/src',98 1 => __DIR__ . '/..' . '/psr/http- factory/src',97 0 => __DIR__ . '/..' . '/psr/http-factory/src', 98 1 => __DIR__ . '/..' . '/psr/http-message/src', 99 99 ), 100 100 'Psr\\Http\\Client\\' => … … 116 116 'Http\\Message\\' => 117 117 array ( 118 0 => __DIR__ . '/..' . '/php-http/message -factory/src',119 1 => __DIR__ . '/..' . '/php-http/message /src',118 0 => __DIR__ . '/..' . '/php-http/message/src', 119 1 => __DIR__ . '/..' . '/php-http/message-factory/src', 120 120 ), 121 121 'Http\\Factory\\Guzzle\\' => -
blockprotocol/trunk/vendor/composer/installed.php
r2886540 r2888447 4 4 'pretty_version' => 'dev-main', 5 5 'version' => 'dev-main', 6 'reference' => ' 0cfe96ccb03939381934792c133c29a90db1ff14',6 'reference' => '73f2ebf03d03a41d55d3ab999e367d0fd7ca22c2', 7 7 'type' => 'wordpress-plugin', 8 8 'install_path' => __DIR__ . '/../../', … … 14 14 'pretty_version' => 'dev-main', 15 15 'version' => 'dev-main', 16 'reference' => ' 0cfe96ccb03939381934792c133c29a90db1ff14',16 'reference' => '73f2ebf03d03a41d55d3ab999e367d0fd7ca22c2', 17 17 'type' => 'wordpress-plugin', 18 18 'install_path' => __DIR__ . '/../../',
Note: See TracChangeset
for help on using the changeset viewer.