Skip to content

Commit

Permalink
phpcs fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sc0ttkclark committed Mar 4, 2018
1 parent 3f9a0d2 commit 370851b
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 41 deletions.
2 changes: 1 addition & 1 deletion sql/update-1.x.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@

if ( is_array( $pods_roles ) ) {
foreach ( $pods_roles as $role => $privs ) {
if ( in_array( 'manage_podpages', $privs ) ) {
if ( in_array( 'manage_podpages', $privs, true ) ) {
$pods_roles[ $role ][] = 'manage_pod_pages';

unset( $pods_roles[ $role ]['manage_podpages'] );
Expand Down
48 changes: 32 additions & 16 deletions sql/update-2.0-beta.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@

// Update to 2.0.0-b-11
if ( version_compare( $pods_version, '2.0.0-b-11', '<' ) ) {
$date_fields = $wpdb->get_results( "
$date_fields = $wpdb->get_results(
"
SELECT `ID`
FROM `{$wpdb->posts}`
WHERE ( `post_name` = 'created' OR `post_name` = 'modified' ) AND `post_type` = '_pods_field'
" );
"
);

if ( ! empty( $date_fields ) ) {
foreach ( $date_fields as $date ) {
Expand All @@ -69,15 +71,17 @@

$_GET = $oldget;

$number_fields = $wpdb->get_results( "
$number_fields = $wpdb->get_results(
"
SELECT `p`.`ID`
FROM `{$wpdb->posts}` AS `p`
LEFT JOIN `{$wpdb->postmeta}` AS `pm` ON `pm`.`post_id` = `p`.`ID`
WHERE
`p`.`post_type` = '_pods_field'
AND `pm`.`meta_key` = 'type'
AND `pm`.`meta_value` = 'number'
" );
"
);

if ( ! empty( $number_fields ) ) {
foreach ( $number_fields as $number ) {
Expand Down Expand Up @@ -150,15 +154,17 @@
pods_no_conflict_on( 'post' );

// convert field types based on options set
$fields = $wpdb->get_results( "
$fields = $wpdb->get_results(
"
SELECT `p`.`ID`
FROM `{$wpdb->posts}` AS `p`
LEFT JOIN `{$wpdb->postmeta}` AS `pm` ON `pm`.`post_id` = `p`.`ID`
WHERE
`p`.`post_type` = '_pods_field'
AND `pm`.`meta_key` = 'type'
AND `pm`.`meta_value` = 'date'
" );
"
);

if ( ! empty( $fields ) ) {
foreach ( $fields as $field ) {
Expand All @@ -185,15 +191,17 @@
}//end foreach
}//end if

$fields = $wpdb->get_results( "
$fields = $wpdb->get_results(
"
SELECT `p`.`ID`
FROM `{$wpdb->posts}` AS `p`
LEFT JOIN `{$wpdb->postmeta}` AS `pm` ON `pm`.`post_id` = `p`.`ID`
WHERE
`p`.`post_type` = '_pods_field'
AND `pm`.`meta_key` = 'type'
AND `pm`.`meta_value` = 'number'
" );
"
);

if ( ! empty( $fields ) ) {
foreach ( $fields as $field ) {
Expand All @@ -214,15 +222,17 @@
}
}

$fields = $wpdb->get_results( "
$fields = $wpdb->get_results(
"
SELECT `p`.`ID`
FROM `{$wpdb->posts}` AS `p`
LEFT JOIN `{$wpdb->postmeta}` AS `pm` ON `pm`.`post_id` = `p`.`ID`
WHERE
`p`.`post_type` = '_pods_field'
AND `pm`.`meta_key` = 'type'
AND `pm`.`meta_value` = 'paragraph'
" );
"
);

if ( ! empty( $fields ) ) {
foreach ( $fields as $field ) {
Expand All @@ -244,15 +254,17 @@
}
}

$fields = $wpdb->get_results( "
$fields = $wpdb->get_results(
"
SELECT `p`.`ID`
FROM `{$wpdb->posts}` AS `p`
LEFT JOIN `{$wpdb->postmeta}` AS `pm` ON `pm`.`post_id` = `p`.`ID`
WHERE
`p`.`post_type` = '_pods_field'
AND `pm`.`meta_key` = 'type'
AND `pm`.`meta_value` = 'text'
" );
"
);

if ( ! empty( $fields ) ) {
foreach ( $fields as $field ) {
Expand Down Expand Up @@ -329,10 +341,14 @@ function pods_2_beta_migrate_type( $id, $options ) {
global $wpdb;

foreach ( $options as $old => $new ) {
$wpdb->query( $wpdb->prepare( "UPDATE `{$wpdb->postmeta}` SET `meta_key` = %s WHERE `meta_key` = %s", array(
$new,
$old,
) ) );
$wpdb->query(
$wpdb->prepare(
"UPDATE `{$wpdb->postmeta}` SET `meta_key` = %s WHERE `meta_key` = %s", array(
$new,
$old,
)
)
);
}
}

Expand Down
2 changes: 1 addition & 1 deletion sql/upgrade/PodsUpgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public function upgraded() {

delete_option( 'pods_framework_upgrade_' . str_replace( '.', '_', $this->version ) );

if ( ! in_array( $this->version, $upgraded ) ) {
if ( ! in_array( $this->version, $upgraded, true ) ) {
$upgraded[] = $this->version;
}

Expand Down
42 changes: 21 additions & 21 deletions sql/upgrade/PodsUpgrade_2_0_0.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function prepare_pods() {
*/
global $wpdb;

if ( ! in_array( "{$wpdb->prefix}pod_types", $this->tables ) ) {
if ( ! in_array( "{$wpdb->prefix}pod_types", $this->tables, true ) ) {
return pods_error( __( 'Table not found, it cannot be migrated', 'pods' ) );
}

Expand All @@ -45,7 +45,7 @@ public function prepare_fields() {
*/
global $wpdb;

if ( ! in_array( "{$wpdb->prefix}pod_fields", $this->tables ) ) {
if ( ! in_array( "{$wpdb->prefix}pod_fields", $this->tables, true ) ) {
return pods_error( __( 'Table not found, it cannot be migrated', 'pods' ) );
}

Expand All @@ -70,7 +70,7 @@ public function prepare_relationships() {
*/
global $wpdb;

if ( ! in_array( "{$wpdb->prefix}pod_rel", $this->tables ) ) {
if ( ! in_array( "{$wpdb->prefix}pod_rel", $this->tables, true ) ) {
return pods_error( __( 'Table not found, it cannot be migrated', 'pods' ) );
}

Expand All @@ -95,7 +95,7 @@ public function prepare_index() {
*/
global $wpdb;

if ( ! in_array( "{$wpdb->prefix}pod", $this->tables ) ) {
if ( ! in_array( "{$wpdb->prefix}pod", $this->tables, true ) ) {
return pods_error( __( 'Table not found, it cannot be migrated', 'pods' ) );
}

Expand All @@ -120,7 +120,7 @@ public function prepare_templates() {
*/
global $wpdb;

if ( ! in_array( "{$wpdb->prefix}pod_templates", $this->tables ) ) {
if ( ! in_array( "{$wpdb->prefix}pod_templates", $this->tables, true ) ) {
return pods_error( __( 'Table not found, it cannot be migrated', 'pods' ) );
}

Expand All @@ -145,7 +145,7 @@ public function prepare_pages() {
*/
global $wpdb;

if ( ! in_array( "{$wpdb->prefix}pod_pages", $this->tables ) ) {
if ( ! in_array( "{$wpdb->prefix}pod_pages", $this->tables, true ) ) {
return pods_error( __( 'Table not found, it cannot be migrated', 'pods' ) );
}

Expand All @@ -170,7 +170,7 @@ public function prepare_helpers() {
*/
global $wpdb;

if ( ! in_array( "{$wpdb->prefix}pod_helpers", $this->tables ) ) {
if ( ! in_array( "{$wpdb->prefix}pod_helpers", $this->tables, true ) ) {
return pods_error( __( 'Table not found, it cannot be migrated', 'pods' ) );
}

Expand Down Expand Up @@ -203,7 +203,7 @@ public function prepare_pod( $params ) {

$pod = pods_sanitize( pods_clean_name( $params->pod ) );

if ( ! in_array( "{$wpdb->prefix}pod_tbl_{$pod}", $this->tables ) ) {
if ( ! in_array( "{$wpdb->prefix}pod_tbl_{$pod}", $this->tables, true ) ) {
return pods_error( __( 'Table not found, it cannot be migrated', 'pods' ) );
}

Expand All @@ -229,7 +229,7 @@ public function prepare_pod( $params ) {

if ( ! empty( $field_rows ) ) {
foreach ( $field_rows as $field ) {
if ( ! in_array( $field->coltype, array( 'pick', 'file' ) ) ) {
if ( ! in_array( $field->coltype, array( 'pick', 'file' ), true ) ) {
$fields[] = $field->name;
}
}
Expand All @@ -240,7 +240,7 @@ public function prepare_pod( $params ) {
$errors = array();

foreach ( $columns as $column => $info ) {
if ( ! in_array( $column, $fields ) ) {
if ( ! in_array( $column, $fields, true ) ) {
$errors[] = "<strong>{$column}</strong> " . __( 'is a field in the table, but was not found in this pod - the field data will not be migrated.', 'pods' );
}
}
Expand Down Expand Up @@ -377,7 +377,7 @@ public function migrate_pods() {

$row->name = pods_clean_name( $row->name );

if ( in_array( $row->name, array( 'created', 'modified', 'author' ) ) ) {
if ( in_array( $row->name, array( 'created', 'modified', 'author' ), true ) ) {
$row->name .= '2';
}

Expand Down Expand Up @@ -412,7 +412,7 @@ public function migrate_pods() {
),
);

if ( in_array( $field_params['name'], $found_fields ) ) {
if ( in_array( $field_params['name'], $found_fields, true ) ) {
continue;
}

Expand Down Expand Up @@ -604,7 +604,7 @@ public function migrate_relationships() {

foreach ( $pod_fields as $field ) {
// Handle name changes
if ( in_array( $field->name, array( 'created', 'modified', 'author' ) ) ) {
if ( in_array( $field->name, array( 'created', 'modified', 'author' ), true ) ) {
$field->name .= '2';
}

Expand All @@ -625,7 +625,7 @@ public function migrate_relationships() {

$field = $types[ $r->datatype ]['fields'][ $types[ $r->datatype ]['old_fields'][ $r->field_id ] ];

if ( ! in_array( $field['type'], array( 'pick', 'file' ) ) ) {
if ( ! in_array( $field['type'], array( 'pick', 'file' ), true ) ) {
continue;
}

Expand Down Expand Up @@ -777,7 +777,7 @@ public function migrate_roles() {

foreach ( $data as $cap ) {
if ( 0 === strpos( 'manage_', $cap ) ) {
if ( in_array( $cap, array( 'manage_roles' ) ) ) {
if ( 'manage_roles' === $cap ) {
continue;
}

Expand Down Expand Up @@ -913,19 +913,19 @@ public function migrate_pod( $params ) {

$pod = pods_sanitize( pods_clean_name( $params->pod ) );

if ( ! in_array( "{$wpdb->prefix}pod_tbl_{$pod}", $this->tables ) ) {
if ( ! in_array( "{$wpdb->prefix}pod_tbl_{$pod}", $this->tables, true ) ) {
return pods_error( __( 'Table not found, items cannot be migrated', 'pods' ) );
}

if ( ! in_array( "{$wpdb->prefix}pods_{$pod}", $this->tables ) ) {
if ( ! in_array( "{$wpdb->prefix}pods_{$pod}", $this->tables, true ) ) {
return pods_error( __( 'New table not found, items cannot be migrated', 'pods' ) );
}

if ( ! in_array( "{$wpdb->prefix}pod_types", $this->tables ) ) {
if ( ! in_array( "{$wpdb->prefix}pod_types", $this->tables, true ) ) {
return pods_error( __( 'Pod Types table not found, items cannot be migrated', 'pods' ) );
}

if ( ! in_array( "{$wpdb->prefix}pod", $this->tables ) ) {
if ( ! in_array( "{$wpdb->prefix}pod", $this->tables, true ) ) {
return pods_error( __( 'Pod table not found, items cannot be migrated', 'pods' ) );
}

Expand All @@ -948,8 +948,8 @@ public function migrate_pod( $params ) {
'created',
'modified',
'author',
)
) && ! in_array( $field['type'], array( 'file', 'pick' ) ) ) {
), true
) && ! in_array( $field['type'], array( 'file', 'pick' ), true ) ) {
$columns[] = pods_sanitize( $field['name'] );
$old_columns[] = pods_var( '_pods_1x_field_name', $field['options'], $field['name'], null, false );
}
Expand Down
4 changes: 2 additions & 2 deletions sql/upgrade/PodsUpgrade_2_1_0.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function migrate_relationships() {
$pod = $this->api->load_pod( array( 'pod' => $field['pod'] ) );

// Only target pods that are meta-enabled
if ( ! in_array( $pod['type'], array( 'post_type', 'media', 'user', 'comment' ) ) ) {
if ( ! in_array( $pod['type'], array( 'post_type', 'media', 'user', 'comment' ), true ) ) {
continue;
}

Expand Down Expand Up @@ -115,7 +115,7 @@ public function restart() {

delete_option( 'pods_framework_upgrade_' . str_replace( '.', '_', $this->version ) );

if ( in_array( $this->version, $upgraded ) ) {
if ( in_array( $this->version, $upgraded, true ) ) {
unset( $upgraded[ array_search( $this->version, $upgraded ) ] );
}

Expand Down

0 comments on commit 370851b

Please sign in to comment.