style.php: unset laptop/tablet "Section side padding" emits padding 0 and overrides desktop value

TITLE: style.php: unset laptop/tablet "Section side padding" emits padding 0 and overrides the desktop value (introduced 28.5.3, still present in 28.5.7)

SUMMARY

Version 28.5.3 fixed the laptop and tablet section-side-padding blocks in style.php — the media queries had been invalid, written as max-width 1440 and max-width 959 with the px unit missing — and at the same time changed the emission gate from a truthiness test to a "greater than or equal to zero" comparison, presumably so that an explicit 0 would be honored.

The side effect is that the gate now fires when the field was never filled in. mfn_opts_get returns its default, null, for an unset key, and in PHP a null compared as greater than or equal to zero evaluates to true. So the blocks emit ".section_wrapper { padding-left: 0px; padding-right: 0px }" between 960 and 1440 pixels and between 768 and 959 pixels on every site where the laptop and tablet values were left empty. The gate can no longer tell "the user chose 0" from "the user never touched this field".

In the current 28.5.7 package these are style.php lines 61 and 69, unchanged since 28.5.3.

A note on presentation: this site's firewall rejects both posts and uploads that contain PHP code, which is why the template code is described in prose here rather than quoted. The exact excerpts with line numbers are ready, and I am happy to send them by whatever channel suits you.

IMPACT

On a site with a non-zero desktop "Section side padding" and the laptop and tablet fields left empty, the desktop rule (emitted from 768 pixels upward) used to apply at all widths of 768 and above — in 28.5.2 the laptop and tablet blocks were dead CSS because of the missing px unit, so they never interfered. After updating, the now-valid laptop and tablet blocks override the desktop padding with 0 across 768 to 1440 pixels. Section side padding silently disappears on tablet and laptop viewports, with no settings change by the site owner.

STEPS TO REPRODUCE

1. In Theme Options, set the desktop "Section side padding" to a non-zero value, for example 30px. Leave the laptop and tablet responsive values empty, never filled.

2. On 28.5.2, view a page at a viewport width between 768 and 1440 pixels. The section wrapper has 30px of side padding, because the desktop rule applies and the laptop and tablet blocks are inert.

3. Update to 28.5.3 or later and reload at the same viewport.

EXPECTED: unset laptop and tablet values inherit the desktop padding, which was the previous effective behavior, while an explicit 0 in those fields overrides it — the apparent intent of the 28.5.3 change.

ACTUAL: the section wrapper side padding becomes 0 between 768 and 1440 pixels. The unset state is treated as an explicit 0.

ONE THING WORTH CHECKING ON YOUR SIDE

MFN_Options::get (options.php, line 620) normalizes an empty saved value back to the same default, returning it whenever the stored value is empty and is not the string "0". So "never saved the options page" and "saved with the field blank" both reach the gate as null, and both emit. There is no blank-versus-unset divergence to work around; the gate simply cannot distinguish any of those states from an explicit 0.

SUGGESTED FIX

Gate on presence rather than on a numeric comparison, so an explicit 0 still emits but an unset or blank value does not: read the option into a variable, then test that its string cast is not empty. Casting null or false to string yields an empty string, so unset and blank behave identically, while the string "0" passes and is emitted. The same change applies to the tablet key. The exact two lines are in the attached file.

RELATED INCONSISTENCY

The desktop block eight lines above, at style.php line 53, still uses the older truthiness gate, so an explicit desktop 0 still cannot emit. If the intent of the 28.5.3 change was to honor an explicit 0, the same presence gate would apply there too.

ENVIRONMENT

Introduced in BeTheme 28.5.3, verified by comparing the 28.5.2 and 28.5.3 packages, and still present unchanged in 28.5.7 — re-verified against the 28.5.7 package, where the two gates are byte-identical at style.php lines 61 and 69. The null comparison behavior is identical on PHP 7 and PHP 8.

While waiting for a response from one of our team members, we recommend to check Support Center where it is highly likely that you will find the answer to your question in no time.

Sign In or Register to comment.
This website uses cookies

We use cookies to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners who may combine it with other information that you’ve provided to them or that they’ve collected from your use of their services.

Cookies are small text files that can be used by websites to make a user's experience more efficient.

The law states that we can store cookies on your device if they are strictly necessary for the operation of this site. For all other types of cookies we need your permission. This means that cookies which are categorized as necessary, are processed based on GDPR Art. 6 (1) (f). All other cookies, meaning those from the categories preferences and marketing, are processed based on GDPR Art. 6 (1) (a) GDPR.

This site uses different types of cookies. Some cookies are placed by third party services that appear on our pages.

You can at any time change or withdraw your consent from the Cookie Declaration on our website.

Learn more about who we are, how you can contact us and how we process personal data in our Privacy Policy.

Please state your consent ID and date when you contact us regarding your consent.