These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * This file removes all of Tabulate's database tables and WordPress options. |
||
4 | * |
||
5 | * @file |
||
6 | * @package Tabulate |
||
7 | */ |
||
8 | |||
9 | if ( ! defined( 'ABSPATH' ) || ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
||
10 | return false; |
||
11 | } |
||
12 | |||
13 | // Make sure all Tabulate classes are accessible. |
||
14 | require __DIR__ . '/vendor/autoload.php'; |
||
15 | |||
16 | // Clear Grants' option. |
||
17 | $grants = new \WordPress\Tabulate\DB\Grants(); |
||
18 | $grants->delete(); |
||
19 | |||
20 | // Drop the ChangeTracker's and Reports' tables. |
||
21 | global $wpdb; |
||
22 | $wpdb->query( 'SET FOREIGN_KEY_CHECKS = 0' ); |
||
23 | foreach ( \WordPress\Tabulate\DB\ChangeTracker::table_names() as $tbl ) { |
||
0 ignored issues
–
show
|
|||
24 | $wpdb->query( "DROP TABLE IF EXISTS `$tbl`;" ); |
||
25 | } |
||
26 | $wpdb->query( "DROP TABLE IF EXISTS `" . \WordPress\Tabulate\DB\Reports::reports_table_name() . "`;" ); |
||
27 | $wpdb->query( "DROP TABLE IF EXISTS `" . \WordPress\Tabulate\DB\Reports::report_sources_table_name() . "`;" ); |
||
28 | $wpdb->query( 'SET FOREIGN_KEY_CHECKS = 1' ); |
||
29 |
There are different options of fixing this problem.
If you want to be on the safe side, you can add an additional type-check:
If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:
Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.