Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions projects/plugins/crm/.phan/baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Invoices: Ensure object owner is properly set.
58 changes: 28 additions & 30 deletions projects/plugins/crm/includes/ZeroBSCRM.Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions projects/plugins/super-cache/.phan/baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Remove redundant code.
3 changes: 0 additions & 3 deletions projects/plugins/super-cache/wp-cache-phase2.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down