diff --git a/projects/plugins/crm/.phan/baseline.php b/projects/plugins/crm/.phan/baseline.php index effe9c14f6070..a4104157706b6 100644 --- a/projects/plugins/crm/.phan/baseline.php +++ b/projects/plugins/crm/.phan/baseline.php @@ -96,7 +96,6 @@ // PhanNoopVariable : 1 occurrence // PhanPluginDuplicateArrayKey : 1 occurrence // PhanPluginDuplicateCatchStatementBody : 1 occurrence - // PhanPluginDuplicateIfCondition : 1 occurrence // PhanPluginUseReturnValueInternalKnown : 1 occurrence // PhanRedefineFunctionInternal : 1 occurrence // PhanSuspiciousWeakTypeComparisonInLoop : 1 occurrence @@ -186,7 +185,7 @@ 'includes/ZeroBSCRM.DataIOValidation.php' => ['PhanTypeMismatchArgument'], 'includes/ZeroBSCRM.Database.php' => ['PhanRedundantCondition', 'PhanSuspiciousValueComparison'], 'includes/ZeroBSCRM.Delete.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentInternal'], - 'includes/ZeroBSCRM.Edit.php' => ['PhanPluginDuplicateIfCondition', 'PhanTypeArraySuspiciousNullable', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentInternal'], + 'includes/ZeroBSCRM.Edit.php' => ['PhanTypeArraySuspiciousNullable', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentInternal'], 'includes/ZeroBSCRM.Encryption.php' => ['PhanUndeclaredConstant'], 'includes/ZeroBSCRM.ExternalSources.php' => ['PhanPluginMixedKeyNoKey', 'PhanPluginUnreachableCode'], 'includes/ZeroBSCRM.FileUploads.php' => ['PhanTypeComparisonFromArray', 'PhanTypeMismatchDimFetch'], diff --git a/projects/plugins/crm/changelog/fix-phan-PhanPluginDuplicateIfCondition b/projects/plugins/crm/changelog/fix-phan-PhanPluginDuplicateIfCondition new file mode 100644 index 0000000000000..b553f5884a758 --- /dev/null +++ b/projects/plugins/crm/changelog/fix-phan-PhanPluginDuplicateIfCondition @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Invoices: Ensure object owner is properly set. diff --git a/projects/plugins/crm/includes/ZeroBSCRM.Edit.php b/projects/plugins/crm/includes/ZeroBSCRM.Edit.php index 5e8a4ee00b547..9e12f7a4daf3f 100644 --- a/projects/plugins/crm/includes/ZeroBSCRM.Edit.php +++ b/projects/plugins/crm/includes/ZeroBSCRM.Edit.php @@ -153,45 +153,43 @@ public function catchPost(){ // check ownership, access etc. public function preChecks(){ - global $zbs; + global $zbs; - $is_malformed_obj = false; + $is_malformed_obj = false; - if (is_array($this->obj) && isset($this->obj['owner'])){ - $obj_owner = (int) $this->obj['owner']; + if ( is_array( $this->obj ) && isset( $this->obj['owner'] ) ) { + $obj_owner = (int) $this->obj['owner']; // Transactions can have a contact or company assigned, and quotes just a contact. This covers checking owners for both. if ( isset( $this->obj['contact'][0]['owner'] ) ) { $obj_owner = (int) $this->obj['contact'][0]['owner']; } elseif ( isset( $this->obj['company'][0]['owner'] ) ) { - $obj_owner = (int) $this->obj['company'][0]['owner']; - // phpcs:disable Generic.WhiteSpace.ScopeIndent.IncorrectExact,Generic.WhiteSpace.ScopeIndent.Incorrect -- this sniff is incorrectly reporting spacing issues. - } - - // This covers checking owners for assigned contacts or companies in invoices. - if ( $this->objTypeID === ZBS_TYPE_INVOICE ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase - $data = zeroBSCRM_invoicing_getInvoiceData( $this->objID ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase - if ( ! empty( $data['invoiceObj']['contact'] ) ) { - $obj_owner = (int) $data['invoiceObj']['contact'][0]['owner']; - } elseif ( ! empty( $data['invoiceObj']['contact'] ) ) { - $obj_owner = (int) $data['invoiceObj']['company'][0]['owner']; - } + $obj_owner = (int) $this->obj['company'][0]['owner']; + } + + // This covers checking owners for assigned contacts or companies in invoices. + if ( $this->objTypeID === ZBS_TYPE_INVOICE ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase + $data = zeroBSCRM_invoicing_getInvoiceData( $this->objID ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase + if ( ! empty( $data['invoiceObj']['contact'] ) ) { + $obj_owner = (int) $data['invoiceObj']['contact'][0]['owner']; + } elseif ( ! empty( $data['invoiceObj']['company'] ) ) { + $obj_owner = (int) $data['invoiceObj']['company'][0]['owner']; } - } else { - // phpcs:enable Generic.WhiteSpace.ScopeIndent.IncorrectExact,Generic.WhiteSpace.ScopeIndent.Incorrect - // if $this->obj is not an array, somehow it's not been loaded properly (probably perms) - // get owner info anyway - $is_malformed_obj = true; - $obj_owner = $zbs->DAL->getObjectOwner( // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase - array( - 'objID' => $this->objID, // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase - 'objTypeID' => $this->objTypeID, // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase - ) - ); - } - // get current user - $current_user_id = get_current_user_id(); + } + } else { + // if $this->obj is not an array, somehow it's not been loaded properly (probably perms) + // get owner info anyway + $is_malformed_obj = true; + $obj_owner = $zbs->DAL->getObjectOwner( // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase + array( + 'objID' => $this->objID, // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase + 'objTypeID' => $this->objTypeID, // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase + ) + ); + } + // get current user + $current_user_id = get_current_user_id(); if ( $obj_owner > 0 && $obj_owner != $current_user_id || $obj_owner == -1 ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseNotEqual,Universal.Operators.StrictComparisons.LooseEqual -- see below. // not current user diff --git a/projects/plugins/super-cache/.phan/baseline.php b/projects/plugins/super-cache/.phan/baseline.php index d40e79dcf9ed3..f109edae11fbd 100644 --- a/projects/plugins/super-cache/.phan/baseline.php +++ b/projects/plugins/super-cache/.phan/baseline.php @@ -40,7 +40,6 @@ // PhanTypeMismatchReturn : 2 occurrences // PhanTypeSuspiciousStringExpression : 2 occurrences // PhanCommentParamWithoutRealParam : 1 occurrence - // PhanPluginDuplicateIfCondition : 1 occurrence // PhanTypeConversionFromArray : 1 occurrence // PhanTypeInvalidLeftOperandOfBitwiseOp : 1 occurrence // PhanTypeInvalidRightOperandOfAdd : 1 occurrence @@ -72,7 +71,7 @@ 'tests/e2e/tools/mu-test-helpers.php' => ['PhanTypeMismatchArgument'], 'wp-cache-base.php' => ['PhanTypeMismatchArgumentNullableInternal'], 'wp-cache-phase1.php' => ['PhanTypeNonVarPassByRef'], - 'wp-cache-phase2.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanPluginDuplicateIfCondition', 'PhanPluginSimplifyExpressionBool', 'PhanPluginUnreachableCode', 'PhanPossiblyUndeclaredVariable', 'PhanSuspiciousValueComparison', 'PhanTypeArraySuspiciousNullable', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentInternalProbablyReal', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeNonVarPassByRef', 'PhanTypePossiblyInvalidDimOffset', 'PhanTypeSuspiciousNonTraversableForeach', 'PhanTypeSuspiciousStringExpression', 'PhanUndeclaredVariableDim'], + 'wp-cache-phase2.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanPluginSimplifyExpressionBool', 'PhanPluginUnreachableCode', 'PhanPossiblyUndeclaredVariable', 'PhanSuspiciousValueComparison', 'PhanTypeArraySuspiciousNullable', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentInternalProbablyReal', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeNonVarPassByRef', 'PhanTypePossiblyInvalidDimOffset', 'PhanTypeSuspiciousNonTraversableForeach', 'PhanTypeSuspiciousStringExpression', 'PhanUndeclaredVariableDim'], 'wp-cache.php' => ['PhanPluginDuplicateAdjacentStatement', 'PhanPluginDuplicateExpressionAssignmentOperation', 'PhanPluginNeverReturnFunction', 'PhanPluginSimplifyExpressionBool', 'PhanPossiblyUndeclaredVariable', 'PhanSuspiciousValueComparison', 'PhanTypeArraySuspiciousNullable', 'PhanTypeInvalidDimOffset', 'PhanTypeInvalidLeftOperandOfBitwiseOp', 'PhanTypeInvalidLeftOperandOfNumericOp', 'PhanTypeInvalidRightOperandOfAdd', 'PhanTypeInvalidRightOperandOfBitwiseOp', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentInternal', 'PhanTypeMismatchArgumentInternalProbablyReal', 'PhanTypeMismatchArgumentInternalReal', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeNonVarPassByRef', 'PhanTypePossiblyInvalidDimOffset', 'PhanTypeSuspiciousNonTraversableForeach', 'PhanUndeclaredFunction', 'PhanUndeclaredVariable', 'PhanUndeclaredVariableDim'], ], // 'directory_suppressions' => ['src/directory_name' => ['PhanIssueName1', 'PhanIssueName2']] can be manually added if needed. diff --git a/projects/plugins/super-cache/changelog/fix-phan-PhanPluginDuplicateIfCondition b/projects/plugins/super-cache/changelog/fix-phan-PhanPluginDuplicateIfCondition new file mode 100644 index 0000000000000..52d344ac735e2 --- /dev/null +++ b/projects/plugins/super-cache/changelog/fix-phan-PhanPluginDuplicateIfCondition @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Remove redundant code. diff --git a/projects/plugins/super-cache/wp-cache-phase2.php b/projects/plugins/super-cache/wp-cache-phase2.php index c7eefb4a90b66..45c99579c59c6 100644 --- a/projects/plugins/super-cache/wp-cache-phase2.php +++ b/projects/plugins/super-cache/wp-cache-phase2.php @@ -2153,9 +2153,6 @@ function wp_cache_ob_callback( $buffer ) { } elseif ( wpsc_is_caching_user_disabled() ) { wp_cache_debug( 'wp_cache_ob_callback: Caching disabled for known user. User logged in or cookie found.' ); $cache_this_page = false; - } elseif ( wp_cache_user_agent_is_rejected() ) { - wp_cache_debug( 'wp_cache_ob_callback: Caching disabled because user agent was rejected.' ); - $cache_this_page = false; } if ( isset( $wpsc_save_headers ) && $wpsc_save_headers ) {