Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix various bugs found when testing strict SQL modes #1947

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion classes/DataWarehouse/Access/ReportGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ReportGenerator extends Common
const REPORT_DATE_REGEX = '/^[0-9]{4}(-[0-9]{2}){2}$/';
const REPORT_FORMATS_REGEX = '/^doc|pdf$/';
const REPORT_SCHEDULE_REGEX = '/^Once|Daily|Weekly|Monthly|Quarterly|Semi-annually|Annually$/';
const REPORT_DELIVERY_REGEX = '/^E-Mail$/';
const REPORT_DELIVERY_REGEX = '/^E-mail$/';

/* Patterns related to report charts */
const REPORT_CHART_TYPE_REGEX = '/^chart_pool|volatile|report|cached$/';
Expand Down
2 changes: 1 addition & 1 deletion classes/OpenXdmod/Setup/AdminUserSetup.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function handle()
$lastName,
array(ROLE_ID_MANAGER, ROLE_ID_USER),
ROLE_ID_MANAGER,
null,
-1,
-1
);

Expand Down
9 changes: 4 additions & 5 deletions classes/XDUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -832,9 +832,9 @@ public function getUpdateQuery($updateToken = false, $includePassword = false)
{
$result = 'UPDATE moddb.Users SET username = :username, email_address = :email_address, first_name = :first_name, middle_name = :middle_name, last_name = :last_name, account_is_active = :account_is_active, person_id = :person_id, organization_id = :organization_id, field_of_science = :field_of_science, user_type = :user_type, sticky = :sticky WHERE id = :id';
if ($updateToken && $includePassword) {
$result = 'UPDATE moddb.Users SET username = :username, password = :password, email_address = :email_address, first_name = :first_name, middle_name = :middle_name, last_name = :last_name, account_is_active = :account_is_active, person_id = :person_id, organization_id = :organization_id, field_of_science = :field_of_science, token = :token, user_type = :user_type, password_last_updated = :password_last_updated, sticky = :sticky WHERE id = :id';
$result = 'UPDATE moddb.Users SET username = :username, password = :password, email_address = :email_address, first_name = :first_name, middle_name = :middle_name, last_name = :last_name, account_is_active = :account_is_active, person_id = :person_id, organization_id = :organization_id, field_of_science = :field_of_science, token = :token, user_type = :user_type, password_last_updated = NOW(), sticky = :sticky WHERE id = :id';
} else if (!$updateToken && $includePassword) {
$result = 'UPDATE moddb.Users SET username = :username, password = :password, email_address = :email_address, first_name = :first_name, middle_name = :middle_name, last_name = :last_name, account_is_active = :account_is_active, person_id = :person_id, organization_id = :organization_id, field_of_science = :field_of_science, user_type = :user_type, password_last_updated = :password_last_updated, sticky = :sticky WHERE id = :id';
$result = 'UPDATE moddb.Users SET username = :username, password = :password, email_address = :email_address, first_name = :first_name, middle_name = :middle_name, last_name = :last_name, account_is_active = :account_is_active, person_id = :person_id, organization_id = :organization_id, field_of_science = :field_of_science, user_type = :user_type, password_last_updated = NOW(), sticky = :sticky WHERE id = :id';
} else if ($updateToken && !$includePassword) {
$result = 'UPDATE moddb.Users SET username = :usernam, email_address = :email_address, first_name = :first_name, middle_name = :middle_name, last_name = :last_name, account_is_active = :account_is_active, person_id = :person_id, organization_id = :organization_id, field_of_science = :field_of_science, token = :token, user_type = :user_type, sticky = :sticky WHERE id = :id';
}
Expand All @@ -857,9 +857,9 @@ public function getInsertQuery($updateToken = false, $includePassword = false)
{
$result = 'INSERT INTO moddb.Users (username, email_address, first_name, middle_name, last_name, account_is_active, person_id, organization_id, field_of_science, user_type, sticky) VALUES (:username, :email_address, :first_name, :middle_name, :last_name, :account_is_active, :person_id, :organization_id, :field_of_science, :user_type, :sticky)';
if ($updateToken && $includePassword) {
$result = 'INSERT INTO moddb.Users (username, password, password_last_updated, email_address, first_name, middle_name, last_name, account_is_active, person_id, organization_id, field_of_science, token, user_type, sticky) VALUES (:username, :password, :password_last_updated, :email_address, :first_name, :middle_name, :last_name, :account_is_active, :person_id, :organization_id, :field_of_science, :token, :user_type, :sticky)';
$result = 'INSERT INTO moddb.Users (username, password, password_last_updated, email_address, first_name, middle_name, last_name, account_is_active, person_id, organization_id, field_of_science, token, user_type, sticky) VALUES (:username, :password, NOW(), :email_address, :first_name, :middle_name, :last_name, :account_is_active, :person_id, :organization_id, :field_of_science, :token, :user_type, :sticky)';
} else if (!$updateToken && $includePassword) {
$result = 'INSERT INTO moddb.Users (username, password, password_last_updated, email_address, first_name, middle_name, last_name, account_is_active, person_id, organization_id, field_of_science, user_type, sticky) VALUES (:username, :password, :password_last_updated, :email_address, :first_name, :middle_name, :last_name, :account_is_active, :person_id, :organization_id, :field_of_science, :user_type, :sticky)';
$result = 'INSERT INTO moddb.Users (username, password, password_last_updated, email_address, first_name, middle_name, last_name, account_is_active, person_id, organization_id, field_of_science, user_type, sticky) VALUES (:username, :password, NOW(), :email_address, :first_name, :middle_name, :last_name, :account_is_active, :person_id, :organization_id, :field_of_science, :user_type, :sticky)';
} else if ($updateToken && !$includePassword) {
$result = 'INSERT INTO moddb.Users (username, email_address, first_name, middle_name, last_name, account_is_active, person_id, organization_id, field_of_science, token, user_type, sticky) VALUES (:username, :email_address, :first_name, :middle_name, :last_name, :account_is_active, :person_id, :organization_id, :field_of_science, :token, :user_type, :sticky)';
}
Expand Down Expand Up @@ -963,7 +963,6 @@ public function saveUser()
$this->_password = password_hash($this->_password, PASSWORD_DEFAULT);
$update_data['password'] = $this->_password;
}
$update_data['password_last_updated'] = 'NOW()';
}
$update_data['email_address'] = ($this->_email);
$update_data['first_name'] = ($this->_firstName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
"avg_logical_usage": "AVG(sf.logical_usage)",
"sum_logical_usage": "SUM(CAST(sf.logical_usage AS DECIMAL(30,0)))",
"sum_squared_logical_usage": "SUM(CAST(sf.logical_usage AS DECIMAL(60,0)) * CAST(sf.logical_usage AS DECIMAL(60,0)))",
"avg_physical_usage": "AVG(sf.physical_usage)",
"sum_physical_usage": "SUM(CAST(sf.physical_usage AS DECIMAL(30,0)))",
"sum_squared_physical_usage": "SUM(CAST(sf.physical_usage AS DECIMAL(60,0)) * CAST(sf.physical_usage AS DECIMAL(60,0)))",
"avg_physical_usage": "AVG(COALESCE(sf.physical_usage, 0))",
"sum_physical_usage": "SUM(CAST(COALESCE(sf.physical_usage, 0) AS DECIMAL(30,0)))",
"sum_squared_physical_usage": "SUM(CAST(COALESCE(sf.physical_usage, 0) AS DECIMAL(60,0)) * CAST(COALESCE(sf.physical_usage, 0) AS DECIMAL(60,0)))",
"avg_soft_threshold": "AVG(sf.soft_threshold)",
"sum_soft_threshold": "SUM(CAST(sf.soft_threshold AS DECIMAL(30,0)))",
"avg_hard_threshold": "AVG(sf.hard_threshold)",
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/lib/TestHarness/UserHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class UserHelper
* @param array|null $acls
* @param string|null $primaryRole
* @param string|null $email
* @param string|null $organizationId
* @param string|null $personId
* @param int $organizationId
* @param int $personId
* @return XDUser
* @throws \Exception
*/
Expand All @@ -33,8 +33,8 @@ public static function getUser(
array $acls = null,
$primaryRole = null,
$email = null,
$organizationId = null,
$personId = null
$organizationId = -1,
$personId = -1
) {
$acls = isset($acls) ? $acls : array(ROLE_ID_USER);
$primaryRole = isset($primaryRole) ? $primaryRole : ROLE_ID_USER;
Expand Down