Copyright message displayed in footer even when empty

Bug #120067 reported by JW
2
Affects Status Importance Assigned to Milestone
Chameleon (inactive)
Fix Released
Low
JW

Bug Description

In the default theme, the copyright and license messages are still displayed in the footer, even when the settings are empty. Because of this, a dot and the text "All texts on this site are licensed under ." is displayed in the footer for no reason.
This error applies only to version 0.6.0.

Revision history for this message
JW (jw-00000) wrote :

This is caused by the fact that in the if's, we use "empty" instead of "empty?" to check if a setting is empty.
The first if should for example be:
  {% if option.general_copyright != empty? %}
Instead of the same but without the question mark.

Changed in chameleon:
status: Unconfirmed → Confirmed
Revision history for this message
JW (jw-00000) wrote :

Next to in the copyright messages in the default theme, this bug also appeared in the <head> section (meta keywords and description) of the Simpla theme and the <head> section and the footer messages of the Scribbish theme.
All occurrences have been fixed, but will only be released in version 0.6.1.

Changed in chameleon:
importance: Undecided → Low
status: Confirmed → Fix Committed
assignee: nobody → jw-00000
Revision history for this message
JW (jw-00000) wrote :

This bug is re-opened.
When comparing two variablesin a condition, Liquid tries to search these variables in the context. So, for example in the condition "option.general_copyright == 2", Liquid searches for context["option.general_copyright"], which returns the setting for the copyright message, and context["2"], which returns the integer 2.
context["empty?"] returns nil, since no variable "empty?" is set.
context["empty"] returns :empty?, the symbol for "empty?", which is set by default in Liquid::Context#resolve. when the second variable in a condition is a symbol, Liquid calls it on the first variable, and returns this value.
So, we should use "empty", as in the original, because this resolves to the symbol :empty?, which is called upon the first variable ("option.general_copyright"), and option.general_copyright.empty? will return whether the copyright message is empty or not.

Changed in chameleon:
status: Fix Committed → In Progress
Revision history for this message
JW (jw-00000) wrote :

The original bug is caused by the fact that when Chameleon is first installed, and the options have never been saved, there exists no such variable as "option.general_copyright". It returns nil, and nil doesn't have a function "empty?", so the condition returns "nil", which is apparently seen as true by Liquid.

Revision history for this message
JW (jw-00000) wrote :

By adding
def nil.empty?; true; end
to vendor/plugins/liquid/lin/liquid/extensions.rb, nil.empty? now returns true.
This means that by writing
{% if option.general_copyright != empty %}
you will get a block that is only evaluated if "option.general_copyright" is not nil and not empty.

JW (jw-00000)
Changed in chameleon:
status: In Progress → Fix Committed
JW (jw-00000)
Changed in chameleon:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.