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

include: fix 'no implicit conversion of nil to String' #5750

Merged
merged 2 commits into from
Jan 14, 2017

Conversation

parkr
Copy link
Member

@parkr parkr commented Jan 10, 2017

This is when either 'dir' or 'file' is nil and passed File.join.

Backtrace
.bundle/ruby/2.3.0/gems/jekyll-3.3.1/lib/jekyll/tags/include.rb:115:in `join'
.bundle/ruby/2.3.0/gems/jekyll-3.3.1/lib/jekyll/tags/include.rb:115:in `block in locate_include_file'
.bundle/ruby/2.3.0/gems/jekyll-3.3.1/lib/jekyll/tags/include.rb:114:in `each'
.bundle/ruby/2.3.0/gems/jekyll-3.3.1/lib/jekyll/tags/include.rb:114:in `locate_include_file'
.bundle/ruby/2.3.0/gems/jekyll-3.3.1/lib/jekyll/tags/include.rb:129:in `render'
.bundle/ruby/2.3.0/gems/liquid-3.0.6/lib/liquid/block.rb:151:in `render_token'
.bundle/ruby/2.3.0/gems/liquid-3.0.6/lib/liquid/profiler/hooks.rb:5:in `block in render_token_with_profiling'
.bundle/ruby/2.3.0/gems/liquid-3.0.6/lib/liquid/profiler.rb:80:in `profile_token_render'
.bundle/ruby/2.3.0/gems/liquid-3.0.6/lib/liquid/profiler/hooks.rb:4:in `render_token_with_profiling'
.bundle/ruby/2.3.0/gems/liquid-3.0.6/lib/liquid/block.rb:135:in `block in render_all'
.bundle/ruby/2.3.0/gems/liquid-3.0.6/lib/liquid/block.rb:122:in `each'
.bundle/ruby/2.3.0/gems/liquid-3.0.6/lib/liquid/block.rb:122:in `render_all'
.bundle/ruby/2.3.0/gems/liquid-3.0.6/lib/liquid/block.rb:108:in `render'
.bundle/ruby/2.3.0/gems/liquid-3.0.6/lib/liquid/template.rb:210:in `block in render'
.bundle/ruby/2.3.0/gems/liquid-3.0.6/lib/liquid/template.rb:262:in `with_profiling'
.bundle/ruby/2.3.0/gems/liquid-3.0.6/lib/liquid/template.rb:209:in `render'
.bundle/ruby/2.3.0/gems/liquid-3.0.6/lib/liquid/template.rb:222:in `render!'
.bundle/ruby/2.3.0/gems/jekyll-3.3.1/lib/jekyll/liquid_renderer/file.rb:28:in `block (2 levels) in render!'
.bundle/ruby/2.3.0/gems/jekyll-3.3.1/lib/jekyll/liquid_renderer/file.rb:40:in `measure_bytes'
.bundle/ruby/2.3.0/gems/jekyll-3.3.1/lib/jekyll/liquid_renderer/file.rb:27:in `block in render!'
.bundle/ruby/2.3.0/gems/jekyll-3.3.1/lib/jekyll/liquid_renderer/file.rb:47:in `measure_time'
.bundle/ruby/2.3.0/gems/jekyll-3.3.1/lib/jekyll/liquid_renderer/file.rb:26:in `render!'
.bundle/ruby/2.3.0/gems/jekyll-3.3.1/lib/jekyll/renderer.rb:134:in `render_liquid'
.bundle/ruby/2.3.0/gems/jekyll-3.3.1/lib/jekyll/renderer.rb:82:in `run'
.bundle/ruby/2.3.0/gems/jekyll-3.3.1/lib/jekyll/site.rb:463:in `block in render_pages'
.bundle/ruby/2.3.0/gems/jekyll-3.3.1/lib/jekyll/site.rb:461:in `each'
.bundle/ruby/2.3.0/gems/jekyll-3.3.1/lib/jekyll/site.rb:461:in `render_pages'
.bundle/ruby/2.3.0/gems/jekyll-3.3.1/lib/jekyll/site.rb:191:in `render'

This is when either 'dir' or 'file' is nil.
@parkr parkr requested a review from benbalter January 10, 2017 17:15
@@ -163,7 +163,7 @@ def load_cached_partial(path, context)
end

def valid_include_file?(path, dir, safe)
!(outside_site_source?(path, dir, safe) || !File.exist?(path))
!(outside_site_source?(path, dir, safe) || !File.file?(path))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want this to be a directory.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not !File.directory?(path) ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe checking to see if it's a file is easier to read - affirmations are easier for us to grok than negations.

Copy link
Member

@ashmaroli ashmaroli Jan 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checking to see if it's a file

but its !File.file?(path) instead of File.file?(path)...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, If anything I'd write this as:

!outside_site_source?(path, dir, safe) && File.file?(path)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me! Updated to Ben's suggestion.

@parkr parkr added this to the 3.3.2 milestone Jan 10, 2017
@parkr parkr self-assigned this Jan 11, 2017
@parkr
Copy link
Member Author

parkr commented Jan 14, 2017

@jekyllbot: merge +bug

@jekyllbot jekyllbot merged commit aa63deb into master Jan 14, 2017
@jekyllbot jekyllbot deleted the no-implicit-conversion-of-nil-to-string branch January 14, 2017 05:01
jekyllbot added a commit that referenced this pull request Jan 14, 2017
@ashmaroli
Copy link
Member

Are we releasing a v3.3.2? Thought the master already had changes that bumped the MINOR version..

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

Successfully merging this pull request may close these issues.

None yet

4 participants