Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[FrameworkBundle] Use relative paths in templates paths cache#19687

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@tgalopin
Copy link
Contributor

@tgalopintgalopin commentedAug 20, 2016
edited
Loading

QA
Branch?master
Bug fix?yes
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#3079
LicenseMIT
Doc PR-

This implements the usage of relative paths instead of absolute ones invar/cache/*/templates.php, important for ability to build the cache in a different context than where it will be used.

This PR transforms the followingtemplates.php:

<?phpreturnarray (':default:index.html.twig' =>'/home/tgalopin/www/symfony-standard/app/Resources/views/default/index.html.twig','::base.html.twig' =>'/home/tgalopin/www/symfony-standard/app/Resources/views/base.html.twig',);

Into:

<?phpreturnarray (':default:index.html.twig' =>__DIR__.'/../../../app/Resources/views/default/index.html.twig','::base.html.twig' =>__DIR__.'/../../../app/Resources/views/base.html.twig',);

I also added tests for the TemplateCachePathsWarmer and improved tests for the TemplateLocator.

{
protected$locator;
protected$cache;
protected$rootDir;
Copy link
Contributor

Choose a reason for hiding this comment

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

should be private I think.

tgalopin reacted with thumbs up emoji
@tgalopintgalopinforce-pushed thetemplates-cache-relative-paths branch 5 times, most recently from6aec93e to2bb53d3CompareAugust 21, 2016 09:40
@tgalopin
Copy link
ContributorAuthor

Travis failure is not related (PHP 7.1 segfault).

$path =$this->locator->locate($template->getPath(),$currentPath);

if ($this->rootDir &&0 ===strpos($path,$this->rootDir)) {
return$this->rootDir.($this->cache[$key] ='./'.substr($path,strlen($this->rootDir)));
Copy link
Contributor

Choose a reason for hiding this comment

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

Tip: As the length of the rootDir doesn't change at runtime you can cache it as a property or static local variable.

tgalopin reacted with thumbs up emoji
@tgalopintgalopinforce-pushed thetemplates-cache-relative-paths branch 5 times, most recently from5276db5 to4f601e8CompareAugust 22, 2016 08:59
@sstok
Copy link
Contributor

LGTM.

@tgalopintgalopinforce-pushed thetemplates-cache-relative-paths branch from4f601e8 to6f6139cCompareAugust 22, 2016 12:31
@nicolas-grekas
Copy link
Member

👍

publicfunction__construct(FileLocatorInterface$locator,$cacheDir =null)
{
if (null !==$cacheDir &&is_file($cache =$cacheDir.'/templates.php')) {
if (null !==$cacheDir &&file_exists($cache =$cacheDir.'/templates.php')) {
Copy link
Member

Choose a reason for hiding this comment

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

Why this change?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

file_exists is faster and is_file have no advantage over it here.

dunglas reacted with thumbs up emoji
@dunglas
Copy link
Member

👍

@fabpot
Copy link
Member

Thank you@tgalopin.

@fabpotfabpot merged commit6f6139c intosymfony:masterAug 23, 2016
fabpot added a commit that referenced this pull requestAug 23, 2016
…s cache (tgalopin)This PR was merged into the 3.2-dev branch.Discussion----------[FrameworkBundle] Use relative paths in templates paths cache| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | yes| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#3079| License       | MIT| Doc PR        | -This implements the usage of relative paths instead of absolute ones in `var/cache/*/templates.php`, important for ability to build the cache in a different context than where it will be used.This PR transforms the following `templates.php`:``` php<?php return array (  ':default:index.html.twig' => '/home/tgalopin/www/symfony-standard/app/Resources/views/default/index.html.twig',  '::base.html.twig' => '/home/tgalopin/www/symfony-standard/app/Resources/views/base.html.twig',);```Into:``` php<?php return array (  ':default:index.html.twig' => __DIR__.'/../../../app/Resources/views/default/index.html.twig',  '::base.html.twig' => __DIR__.'/../../../app/Resources/views/base.html.twig',);```I also added tests for the TemplateCachePathsWarmer and improved tests for the TemplateLocator.Commits-------6f6139c [FrameworkBundle] Use relative paths in templates paths cache
@tgalopintgalopin deleted the templates-cache-relative-paths branchAugust 23, 2016 17:58
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

7 participants

@tgalopin@sstok@nicolas-grekas@dunglas@fabpot@hhamon@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp