Skip to content

fix template class name generation to prevent possible collisions#1852

Merged
fabpot merged 1 commit intotwigphp:1.xfrom
Tobion:fix-possible-class-conflicts
Oct 4, 2015
Merged

fix template class name generation to prevent possible collisions#1852
fabpot merged 1 commit intotwigphp:1.xfrom
Tobion:fix-possible-class-conflicts

Conversation

@Tobion
Copy link
Copy Markdown
Contributor

@Tobion Tobion commented Sep 24, 2015

Comment thread lib/Twig/Cache/Filesystem.php Outdated
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

using one directory instead of two saves 1 inode per file. the file distribution stays the same. even though the math in #1684 is wrong, I agree that this diversity is enough.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It was done with a hash because of your comment here: #1822 (comment)

👎 for this change. The getTemplateClass() is public and can be changed in any way.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I know. I'm just trying to make it as fast as possible by default and avoid hashing the hash for every template on each request. Maybe we should remove the directory balancing at all by default. Todays filesystems do not have a limitation on number of files per directory. And also most users, won't have thousands of templates anyway where it could matter. And if people really have this need they can change the filesystem cache themselves. No need to hurt everybody by default.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This was added because some of our customers had this problem.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah but IMO performance-relevant things that only affect a small subset of people should be opt-in and not opt-out. Even more so now that the caching implementation can easily be adapted.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No, Twig should work for everyone and it is the case right now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

reverted even though I don't fully agree. It can never work for everyone as it depends on the filesystem and the number of templates you have. So whatever workaround you add it can always be the wrong one depending on who is using it.

@Tobion Tobion changed the title fix template class name generation to prevent possible collisions [WIP] fix template class name generation to prevent possible collisions Sep 29, 2015
@Tobion Tobion changed the title [WIP] fix template class name generation to prevent possible collisions fix template class name generation to prevent possible collisions Oct 3, 2015
@fabpot
Copy link
Copy Markdown
Contributor

fabpot commented Oct 4, 2015

Thank you @Tobion.

@fabpot fabpot merged commit f379e81 into twigphp:1.x Oct 4, 2015
fabpot added a commit that referenced this pull request Oct 4, 2015
…isions (Tobion)

This PR was merged into the 1.x branch.

Discussion
----------

fix template class name generation to prevent possible collisions

- fix template class name generation to prevent possible collisions
- save one inode per file
- fix tests as they are broken with the cext since #1844

Commits
-------

f379e81 fix template class name generation to prevent possible collisions and one inode per file
@Tobion Tobion deleted the fix-possible-class-conflicts branch October 4, 2015 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

6 participants