Skip to content

Conversation

@nicolas-grekas
Copy link
Member

@nicolas-grekas nicolas-grekas commented Oct 29, 2025

Q A
Branch? 7.4
Bug fix? no
New feature? no
Deprecations? no
Issues #62202
License MIT

This allows specifying explicitly when the app has no share dir.

If the method returns null, the kernel.share_dir parameter is not defined.
This gives a nice way to spot where references to this parameter remain with You have requested a non-existent parameter "kernel.share_dir" exceptions as a hint.

Setting the APP_SHARE_DIR env var to any falsy value (off, false, 0, etc as supported by filter_var()) will lead to configuring the app with no share dir.

@GromNaN
Copy link
Member

GromNaN commented Oct 29, 2025

This allows specifying explicitly when the app has no share dir.

In that case, app cache directory have to be set back to %kernel.cache_dir%/pools/app.
Using a non-shared for app cache is not always an issue.

@xabbuh
Copy link
Member

xabbuh commented Oct 29, 2025

the changes from #62191 also need to be addressed

@nicolas-grekas
Copy link
Member Author

nicolas-grekas commented Oct 29, 2025

In that case, app cache directory have to be set back to %kernel.cache_dir%/pools/app.

nope: that's exactly the kind of config you want to spot early on: if you go with no share dir, your app cache pools have to be configured to use eg Redis by default (or you might be fine with using the cache-dir, but it shouldn't be our call by default)

@nicolas-grekas
Copy link
Member Author

the changes from #62191 also need to be addressed

indeed, PR updated

@nicolas-grekas nicolas-grekas added ❄️ Feature Freeze Important Pull Requests to finish before the next Symfony "feature freeze" and removed Feature labels Oct 29, 2025
@GromNaN
Copy link
Member

GromNaN commented Oct 29, 2025

nope: that's exactly the kind of config you want to spot early on: if you go with no share dir, your app cache pools have to be configured to use eg Redis by default (or you might be fine with using the cache-dir, but it shouldn't be our call by default)

Ok, I understand the intention better now. The fallback on cache_dir is a bit strange in that we only get an error only if we explicitly indicate that we don't have a share_dir, which is the default for multi-server deployments. There is no way to know if we are running on a single server or a cluster of servers without nfs.

@nicolas-grekas
Copy link
Member Author

Sure. We don't want to disrupt the defaults.
What's nice about this is that it's opt-in: ppl that care will now be able to spot when some subsytem relies on a share dir and need to be reconfigured.

Comment on lines 308 to 309
// Returns $this->getCacheDir() for backward compatibility
return $this->getCacheDir();
Copy link
Contributor

Choose a reason for hiding this comment

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

should this not be now return null; ?

Copy link
Member Author

Choose a reason for hiding this comment

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

nope: we want to null to be opt-in

@nicolas-grekas nicolas-grekas deleted the no-share-dir branch October 31, 2025 12:30

public function testGetShareDirDisabledByEnv()
{
$previous = $_SERVER['APP_SHARE_DIR'] ?? null;
Copy link
Member

Choose a reason for hiding this comment

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

Is this needed? PHPUnit does restore the $_SERVER array after each test if the backup globale feature isn’t disabled, doesn’t it?

Copy link
Member Author

Choose a reason for hiding this comment

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

that's quite possible 😬

Copy link
Member

Choose a reason for hiding this comment

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

FTR, it's the opposite: #62273

@Kocal
Copy link
Member

Kocal commented Oct 31, 2025

Hey!

I think this PR broke UX test-suite on based Symfony 8: https://github.com/symfony/ux/actions/runs/18986901497/job/54232436997?pr=3154

PHP Fatal error: Declaration of Symfony\UX\LiveComponent\Tests\Fixtures\Kernel::getShareDir(): ?string must be compatible with Symfony\Component\HttpKernel\Kernel::getShareDir(): string in /home/runner/work/ux/ux/src/LiveComponent/vendor/symfony/framework-bundle/Kernel/MicroKernelTrait.php on line 127

I'm not sure, but maybe a Composer conflict must be configured?

@nicolas-grekas
Copy link
Member Author

@Kocal it's just that the change wasn't merged yet into 8.0. I did it now.

@Kocal
Copy link
Member

Kocal commented Nov 1, 2025

Thanks, that's perfect now :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

HttpKernel ❄️ Feature Freeze Important Pull Requests to finish before the next Symfony "feature freeze" Status: Reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants