File tree Expand file tree Collapse file tree 3 files changed +14
-1
lines changed
private/AppFramework/Utility Expand file tree Collapse file tree 3 files changed +14
-1
lines changed Original file line number Diff line number Diff line change 27432743 * Defaults to true.
27442744 */
27452745'files.trash.delete ' => true ,
2746+
2747+ /**
2748+ * Enable lazy objects feature from PHP 8.4 to be used in the Dependency Injection.
2749+ * Should improve performances by avoiding buiding unused objects.
2750+ *
2751+ * Defaults to false.
2752+ */
2753+ 'enable_lazy_objects ' => false ,
27462754];
Original file line number Diff line number Diff line change @@ -618,6 +618,9 @@ public static function init(): void {
618618 }
619619 $ loaderEnd = microtime (true );
620620
621+ // Enable lazy loading if activated
622+ \OC \AppFramework \Utility \SimpleContainer::$ useLazyObjects = (bool )self ::$ config ->getValue ('enable_lazy_objects ' );
623+
621624 // setup the basic server
622625 self ::$ server = new \OC \Server (\OC ::$ WEBROOT , self ::$ config );
623626 self ::$ server ->boot ();
Original file line number Diff line number Diff line change 2424 * SimpleContainer is a simple implementation of a container on basis of Pimple
2525 */
2626class SimpleContainer implements ArrayAccess, ContainerInterface, IContainer {
27+ public static bool $ useLazyObjects = false ;
28+
2729 private Container $ container ;
2830
2931 public function __construct () {
@@ -58,7 +60,7 @@ private function buildClass(ReflectionClass $class): object {
5860 /* No constructor, return a instance directly */
5961 return $ class ->newInstance ();
6062 }
61- if (PHP_VERSION_ID >= 80400 ) {
63+ if (PHP_VERSION_ID >= 80400 && self :: $ useLazyObjects ) {
6264 /* For PHP>=8.4, use a lazy ghost to delay constructor and dependency resolving */
6365 /** @psalm-suppress UndefinedMethod */
6466 return $ class ->newLazyGhost (function (object $ object ) use ($ constructor ): void {
You can’t perform that action at this time.
0 commit comments