-
-
Notifications
You must be signed in to change notification settings - Fork 5k
feat: frankenphp #58541
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
Open
CarlSchwan
wants to merge
11
commits into
master
Choose a base branch
from
carl/frankenphp
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,636
−1,381
Open
feat: frankenphp #58541
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5634fd7
feat: frankenphp
CarlSchwan c367249
feat: enabled frankenphp worker mode
CarlSchwan 918972e
fix: Change back base.php to have the same behavior as before
come-nc 0a6ebc2
fix: cleanup some of the static vars
come-nc 31ad387
feat: Add command in testing application to hunt for static properties
come-nc 18481ab
feat: Add support for application namespaces in testing:static-hunt
come-nc d5ed9eb
refactor: Fix rebasing issues
CarlSchwan 0ddb034
fix(filesystem): reset static members during frankenphp invokations
CarlSchwan 20464c0
fix: Improve detection of frankenphp worker mode
CarlSchwan 50d0ab9
fix: Add back logging for autoloading time
CarlSchwan 96f1cf8
fix: Remove workaround for old version of frankenphp
CarlSchwan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| localhost { | ||
| php_server { | ||
| worker index.php | ||
| } | ||
|
|
||
| log { | ||
| level ERROR | ||
| output stderr | ||
| } | ||
|
|
||
| encode gzip | ||
|
|
||
| redir /.well-known/carddav /remote.php/dav 301 | ||
| redir /.well-known/caldav /remote.php/dav 301 | ||
|
|
||
| # Rule: Maps most RFC 8615 compliant well-known URIs to our main frontend controller (/index.php) by default | ||
| @wellKnown { | ||
| path "/.well-known/" | ||
| not { | ||
| path /.well-known/acme-challenge | ||
| path /.well-known/pki-validation | ||
| } | ||
| } | ||
| rewrite @wellKnown /index.php | ||
|
|
||
| rewrite /ocm-provider/ /index.php | ||
|
|
||
| @forbidden { | ||
| path /.htaccess | ||
| path /data/* | ||
| path /config/* | ||
| path /db_structure | ||
| path /.xml | ||
| path /README | ||
| path /3rdparty/* | ||
| path /lib/* | ||
| path /templates/* | ||
| path /occ | ||
| path /build | ||
| path /tests | ||
| path /console.php | ||
| path /autotest | ||
| path /issue | ||
| path /indi | ||
| path /db_ | ||
| path /console | ||
| } | ||
| respond @forbidden 404 | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| namespace OCA\Testing\Command; | ||
|
|
||
| use OCP\App\IAppManager; | ||
| use Symfony\Component\Console\Command\Command; | ||
| use Symfony\Component\Console\Input\InputInterface; | ||
| use Symfony\Component\Console\Output\OutputInterface; | ||
|
|
||
| class StaticHunt extends Command { | ||
| private const array SKIP_REGEX = [ | ||
| '@/templates/.+.php$@', | ||
| '@/ajax/.+.php$@', | ||
| '@/register_command.php$@', | ||
| ]; | ||
|
|
||
| public function __construct( | ||
| private IAppManager $appManager, | ||
| ) { | ||
| parent::__construct(); | ||
| } | ||
|
|
||
| protected function configure() { | ||
|
Check failure on line 30 in apps/testing/lib/Command/StaticHunt.php
|
||
| $this | ||
| ->setName('testing:static-hunt') | ||
| ->setDescription('Hunt for static properties in classes'); | ||
| } | ||
|
|
||
|
|
||
| protected function execute(InputInterface $input, OutputInterface $output): int { | ||
|
Check failure on line 37 in apps/testing/lib/Command/StaticHunt.php
|
||
| $folders = [ | ||
| '' => __DIR__ . '/../../../../lib/private/legacy', | ||
| '\\OC' => __DIR__ . '/../../../../lib/private', | ||
| '\\OC\\Core' => __DIR__ . '/../../../../core', | ||
| ]; | ||
| $apps = $this->appManager->getAllAppsInAppsFolders(); | ||
| foreach ($apps as $app) { | ||
| $info = $this->appManager->getAppInfo($app); | ||
| if (!isset($info['namespace'])) { | ||
| continue; | ||
| } | ||
| $folders['\\OCA\\' . $info['namespace']] = $this->appManager->getAppPath($app) . '/lib'; | ||
| } | ||
| $stats = [ | ||
| 'classes' => 0, | ||
| 'properties' => 0, | ||
| ]; | ||
| foreach ($folders as $namespace => $folder) { | ||
| $this->scanFolder($folder, $namespace, $output, $stats); | ||
| } | ||
|
|
||
| $output->writeln('<info>Found ' . $stats['properties'] . ' static properties spread among ' . $stats['classes'] . ' classes</info>'); | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| private function scanFolder(string $folder, string $namespace, OutputInterface $output, array &$stats): void { | ||
| $folder = realpath($folder); | ||
| $output->writeln('Folder ' . $folder, OutputInterface::VERBOSITY_VERBOSE); | ||
| foreach ($this->recursiveGlob($folder) as $filename) { | ||
| try { | ||
| $filename = realpath($filename); | ||
| if (($namespace === '\\OC') && str_contains($filename, 'lib/private/legacy')) { | ||
| // Skip legacy in OC as it’s scanned with an empty namespace separately | ||
| continue; | ||
| } | ||
| foreach (self::SKIP_REGEX as $skipRegex) { | ||
| if (preg_match($skipRegex, $filename)) { | ||
| continue 2; | ||
| } | ||
| } | ||
| $classname = $namespace . substr(str_replace('/', '\\', substr($filename, strlen($folder))), 0, -4); | ||
| $output->writeln('Class ' . $classname, OutputInterface::VERBOSITY_VERBOSE); | ||
| if (!class_exists($classname)) { | ||
| continue; | ||
| } | ||
| $rClass = new \ReflectionClass($classname); | ||
| $staticProperties = $rClass->getStaticProperties(); | ||
| if (empty($staticProperties)) { | ||
| continue; | ||
| } | ||
| $stats['classes']++; | ||
| $output->writeln('<info># ' . str_replace(\OC::$SERVERROOT, '', $filename) . " $classname</info>"); | ||
| foreach ($staticProperties as $property => $value) { | ||
| $propertyObject = $rClass->getProperty($property); | ||
| $stats['properties']++; | ||
| $output->write("$propertyObject"); | ||
| } | ||
| $output->writeln(''); | ||
| } catch (\Throwable $t) { | ||
| $output->writeln("$t"); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private function recursiveGlob(string $path, int $depth = 1): \Generator { | ||
| $pattern = $path . str_repeat('/*', $depth); | ||
| yield from glob($pattern . '.php'); | ||
| if (!empty(glob($pattern, GLOB_ONLYDIR))) { | ||
| yield from $this->recursiveGlob($path, $depth + 1); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
watch directive should be added for upgrades: https://frankenphp.dev/docs/config/#watching-for-file-changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's already on by default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reference needed