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

Unintentional type casting breaks display of custom fields for domains #97

Closed
alexkuc opened this issue Feb 28, 2019 · 3 comments
Closed
Assignees

Comments

@alexkuc
Copy link

alexkuc commented Feb 28, 2019

While testing domainMOD software (really awesome software by the way!) I came across a bizarre scenario. On my local machine (Mac/MAMP Pro) custom fields were displaying fine (on the main page with domains) but on my hosting (SiteGround/shared hosting) the custom fields did not appear on the main page with domains. After long digging, I found out that the culprit. On my remote hosting (SiteGround) some of the variables from array $_SESSION['s_cdf_data'] became string instead of integer (verified via gettype()). Because of this unintentional type juggling, strict comparison became broken:

domainmod/domains/index.php

Lines 2353 to 2359 in c290292

<?php if ($_SESSION['s_cdf_data']) {
foreach ($_SESSION['s_cdf_data'] as $field) {
if ($field['value'] === 1 && $field['type_id'] != '3') { // Don't show column for Text Areas ?>
<th<?php if ($_SESSION['s_system_large_mode'] == '1') { echo ' style="padding-left:20px;"'; } ?>>

domainmod/domains/index.php

Lines 2469 to 2509 in c290292

<?php if ($_SESSION['s_cdf_data']) {
foreach ($_SESSION['s_cdf_data'] as $field) {
if ($field['value'] === 1 && $field['type_id'] != '3') { // Don't show data for Text Areas ?>
<td<?php if ($_SESSION['s_system_large_mode'] == '1') { echo ' style="padding-left:20px;"'; } ?>><?php
if ($field['type_id'] === 1) { // Check Box
echo ($row->{$field['field']} === 1 ? 'Yes' : 'No');
} elseif ($field['type_id'] === 2) { // Text
echo $row->{$field['field']};
} elseif ($field['type_id'] === 4) { // Date
if ($row->{$field['field']} == '1970-01-01') {
echo '';
} else {
echo $row->{$field['field']};
}
} elseif ($field['type_id'] === 5) { // Time Stamp
if ($row->{$field['field']} == '1970-01-01 00:00:00') {
echo '';
} else {
echo $row->{$field['field']};
}
} ?>

I used two workarounds: either coerce $_SESSION into integer via (int) $_SESSION[$variable] or use relaxed comparison (i.e. == instead of ===).

I am not proficient enough in PHP to be able to judge whether this is an isolated case relating purely to my environment or if someone else could encounter the same issue.

@chetcuti chetcuti self-assigned this May 3, 2020
@chetcuti
Copy link
Member

chetcuti commented May 3, 2020

Hmm, that's very strange indeed. I'm going to investigate this further, but in the meantime I've switched the relevant identical operators back to the equals operators so that this functions properly. This has been put into the development code already, and will be getting pushed out in an official release in the next couple weeks.

Since this works in one environment but not the other, I wonder if this is some sort of a PHP setting that's disabled on your shared hosting account. Or a maybe related to a security setting somewhere, since shared hosting tends to be a bit more locked down. Do you happen to know what PHP version your shared hosting runs? And I'm guessing you have no access to your PHP configuration on the shared hosting server, correct?

@alexkuc
Copy link
Author

alexkuc commented May 3, 2020

Do you happen to know what PHP version your shared hosting runs?

I believe it was 7.x. Don't remember sub-version unfortunately. But the major version is 7 for sure.

And I'm guessing you have no access to your PHP configuration on the shared hosting server, correct?

Actually, SiteGround allows to do that. Unfortunately, I am not able to get that information as I am no longer with the company where I was using DomainMOD software.

@chetcuti
Copy link
Member

Those identical operators seem to cause issues way too often. I've gone ahead and changed some of them back to ==, and will investigate changing even more back in the future.

Thanks a lot for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants