Closed lerni closed 4 years ago
I tried using your command on my local 4.6.0 and it worked fine for me. Can you provide more details on your set up?
I've reproduced this with a fresh SS 4.6 install. I'm using a Hombrew Stack with php 7.3. Steps to reproduce bellow:
composer create-project silverstripe/installer sspaktest
composer require silverstripe/sspak --dev
.env
/dev/build
./vendor/bin/sspak save . ./test.sspak
#!/usr/bin/env php
PHP Fatal error: Uncaught LogicException: You must call one of in() or append() methods before iterating over a Finder. in /webroot/sspaktest/vendor/symfony/finder/Finder.php:569
Stack trace:
#0 /webroot/sspaktest/vendor/silverstripe/config/src/Transformer/YamlTransformer.php(78): Symfony\Component\Finder\Finder->getIterator()
#1 /webroot/sspaktest/vendor/silverstripe/config/src/Transformer/YamlTransformer.php(90): SilverStripe\Config\Transformer\YamlTransformer->__construct('/Users/...', Object(Symfony\Component\Finder\Finder))
#2 /webroot/sspaktest/vendor/silverstripe/framework/src/Core/Config/CoreConfigFactory.php(140): SilverStripe\Config\Transformer\YamlTransformer::create('/Users/...', Object(Symfony\Component\Finder\Finder))
#3 /webroot/sspaktest/vendor/silverstripe/framework/src/Core/Config/CoreConfigFactory.php(113): SilverStripe\Core\Config\CoreConfigFactory->buildYamlTransformerForPath(Array)
#4 /webroot/ in /webroot/sspaktest/vendor/symfony/finder/Finder.php on line 569
Command: /usr/bin/env 'php' '/tmp/sspak-sniffer-669306.php' '.'
Execution failed: returned 255.
Output:
Fatal error: Uncaught LogicException: You must call one of in() or append() methods before iterating over a Finder. in /webroot/sspaktest/vendor/symfony/finder/Finder.php:569 Stack trace:
@lerni I tried locally following your instructions, works fine on my setup (vagrant)
/dev/build
what happens when you /dev/build?flush
?
https://github.com/silverstripe/silverstripe-framework/commit/e08bf1cdd96ea2930b2a41162eaad384404c1672#diff-60a4ca169ca76e21bcddfb53bb8022d9R187 means the cache should be cleared on flush
@maxime-rainville @emteknetnz thank you both taking time to check this! :heart: :thumbsup:
Steve asked to check dev/build?flush=1
and I found a strange thing that just happens with PHP 7.3, not with 7.2 and not with 7.4! If I flush per HTTP and than run sspak
it errors as described above, if I first flush per CLI (sake) it runs through ;)
Next week I’ll hopefully find time to compare config for those PHP-Versions or patch update 7.3 and see if it makes a difference. I’ll report back and close if appropriate. Or what else would you check?
I have the same error running on php 7.3.14, on a clean container. I'll document some stuff here for reference an
root@4ba1035c6680:/var/www# sspak load [dump-file].sspak
[23-Jul-2020 03:54:26 UTC] PHP Fatal error: Uncaught LogicException: You must call one of in() or append() methods before iterating over a Finder. in /var/www/vendor/symfony/finder/Finder.php:569
Stack trace:
#0 /var/www/vendor/silverstripe/config/src/Transformer/YamlTransformer.php(78): Symfony\Component\Finder\Finder->getIterator()
#1 /var/www/vendor/silverstripe/config/src/Transformer/YamlTransformer.php(90): SilverStripe\Config\Transformer\YamlTransformer->__construct('/var/www', Object(Symfony\Component\Finder\Finder))
#2 /var/www/vendor/silverstripe/framework/src/Core/Config/CoreConfigFactory.php(140): SilverStripe\Config\Transformer\YamlTransformer::create('/var/www', Object(Symfony\Component\Finder\Finder))
#3 /var/www/vendor/silverstripe/framework/src/Core/Config/CoreConfigFactory.php(113): SilverStripe\Core\Config\CoreConfigFactory->buildYamlTransformerForPath(Array)
#4 /var/www/vendor/silverstripe/framework/src/Core/Config/CoreConfigFactory.php(91): SilverStripe\Core\Config\CoreConfigFactory->buildYamlTransformer()
#5 /var/www/vendor/silvers in /var/www/vendor/symfony/finder/Finder.php on line 569
Command: /usr/bin/env 'php' '/tmp/sspak-sniffer-577601.php' '.'
Execution failed: returned 255.
Output:
Fatal error: Uncaught LogicException: You must call one of in() or append() methods before iterating over a Finder. in /var/www/vendor/symfony/finder/Finder.php:569
Stack trace:
#0 /var/www/vendor/silverstripe/config/src/Transformer/YamlTransformer.php(78): Symfony\Component\Finder\Finder->getIterator()
#1 /var/www/vendor/silverstripe/config/src/Transformer/YamlTransformer.php(90): SilverStripe\Config\Transformer\YamlTransformer->__construct('/var/www', Object(Symfony\Component\Finder\Finder))
#2 /var/www/vendor/silverstripe/framework/src/Core/Config/CoreConfigFactory.php(140): SilverStripe\Config\Transformer\YamlTransformer::create('/var/www', Object(Symfony\Component\Finder\Finder))
#3 /var/www/vendor/silverstripe/framework/src/Core/Config/CoreConfigFactory.php(113): SilverStripe\Core\Config\CoreConfigFactory->buildYamlTransformerForPath(Array)
#4 /var/www/vendor/silverstripe/framework/src/Core/Config/CoreConfigFactory.php(91): SilverStripe\Core\Config\CoreConfigFactory->buildYamlTransformer()
#5 /var/www/vendor/silvers in /var/www/vendor/symfony/finder/Finder.php on line 569
root@4ba1035c6680:/var/www# php -v
PHP 7.3.14 (cli) (built: Feb 1 2020 20:10:52) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.14, Copyright (c) 1998-2018 Zend Technologies
This is the output for composer show
asyncphp/doorman 3.1.0 Child process management
beberlei/assert v3.2.7 Thin assertion library for input validation in business models.
bramus/ansi-php 3.0.3 ANSI Control Functions and ANSI Control Sequences (Colors, Erasing,...
bramus/monolog-colored-line-formatter 2.0.3 Colored Line Formatter for Monolog
clue/stream-filter v1.4.1 A simple and modern approach to stream filtering in PHP
colymba/gridfield-bulk-editing-tools 3.0.0 SilverStripe GridField component to upload images/files and edit re...
composer/ca-bundle 1.2.7 Lets you find a path to the system CA bundle, and includes a fallba...
composer/installers v1.9.0 A multi-framework Composer library installer
composer/package-versions-deprecated 1.10.99 Composer plugin that provides efficient querying for installed pack...
cwp/agency-extensions 2.4.0 Base module for the default CWP theme to add features
cwp/cwp 2.6.0 CWP features module. We strongly recommend using it for all new sit...
cwp/cwp-core 2.6.0 CWP basic compatibility module. Use for migrations.
cwp/cwp-pdfexport 1.1.1 Add PDF export capability for pages in CWP
cwp/cwp-recipe-cms 2.6.0 CWP CMS requirements recipe
cwp/cwp-recipe-core 2.6.0 CWP core requirements recipe
cwp/cwp-recipe-search 2.6.0 CWP search requirements recipe
cwp/cwp-search 1.3.0 CWP fulltextsearch integration module
defuse/php-encryption v2.2.1 Secure PHP Encryption Library
dnadesign/silverstripe-elemental 4.4.0 Elemental pagetype and collection of Elements
dnadesign/silverstripe-elemental-list 1.2.0 Adds a new element for nested elements
dnadesign/silverstripe-elemental-userforms 3.0.0 Adds a new element for usersforms
doctrine/instantiator 1.3.1 A small, lightweight utility to instantiate objects in PHP without ...
dynamic/flexslider 4.1.0 Display a FlexSlider on pages of your website
dynamic/silverstripe-country-dropdown-field 1.2.0 A simple country dropdown field for SilverStripe forms
dynamic/silverstripe-elemental-accordion 2.1.0 Display content in collapsable panels
dynamic/silverstripe-elemental-baseobject 2.1.0 A simple base DataObject to use with Elemental Content Blocks
dynamic/silverstripe-elemental-blocks 3.0.1 A recipe to require additional elements for the SilverStripe Elemen...
dynamic/silverstripe-elemental-blog 2.1.2 Show recent posts from a featured blog.
dynamic/silverstripe-elemental-countdown 2.0.3 Display a countdown to a specific date and time
dynamic/silverstripe-elemental-customer-service 2.0.4 Additional customer service element for the SilverStripe Elemental ...
dynamic/silverstripe-elemental-embedded-code 2.0.2 Embed code like iFrames or Javascript on a page.
dynamic/silverstripe-elemental-features 2.0.5 A block that displays featured content - large image, title, descri...
dynamic/silverstripe-elemental-filelist 2.0.2 A multi file block for SilverStripe Elemental
dynamic/silverstripe-elemental-flexslider 2.0.2 Flexslider slideshow content block for SilverStripe Elemental
dynamic/silverstripe-elemental-gallery 2.0.5 A block to display a collection of images
dynamic/silverstripe-elemental-image 2.0.1 A block to add a single image to your page.
dynamic/silverstripe-elemental-oembed 2.2.0 A block to embed media from other websites via oEmbed
dynamic/silverstripe-elemental-promos 2.0.3 A content block to display a group of promos
dynamic/silverstripe-elemental-section-navigation 2.0.2 A block to display a list of links to child pages, or pages in curr...
dynamic/silverstripe-elemental-sponsors 2.0.1 Display a list of sponsor logos with links.
dynamic/silverstripe-elemental-tabset 2.0.1 Create a tabbed interface that uses elements
dynamic/silverstripe-elemental-testimonials 2.0.1 Testimonials element for the SilverStripe Elemental Module
dynamic/silverstripe-geocoder 1.1.1 SilverStripe wrapper for Geocoder
dynamic/silverstripe-linkable 1.0.2 A couple of handy form fields and objects for managing external and...
egeloen/http-adapter 0.8.0 Issue HTTP request for PHP 5.3+.
embed/embed v3.4.8 PHP library to retrieve page info using oembed, opengraph, etc
guzzlehttp/guzzle 6.5.5 Guzzle is a PHP HTTP client library
guzzlehttp/promises v1.3.1 Guzzle promises library
guzzlehttp/psr7 1.6.1 PSR-7 message implementation that also provides common utility methods
http-interop/http-factory-guzzle 1.0.0 An HTTP Factory using Guzzle PSR7
igorw/get-in v1.0.3 Functions for for hash map (assoc array) traversal.
intervention/image 2.5.1 Image handling and manipulation library with support for Laravel in...
jean85/pretty-package-versions 1.5.0 A wrapper for ocramius/package-versions to get pretty versions strings
jeremeamia/superclosure 2.4.0 Serialize Closure objects, including their context and binding
league/csv 8.2.3 Csv data manipulation made easy in PHP
league/flysystem 1.0.69 Filesystem abstraction: Many filesystems, one API.
m1/env 2.2.0 Env is a lightweight library bringing .env file parser compatibilit...
marcj/topsort 1.1.0 High-Performance TopSort/Dependency resolving algorithm
monolog/monolog 1.25.4 Sends your logs to files, sockets, inboxes, databases and various w...
myclabs/deep-copy 1.10.1 Create deep copies (clones) of your objects
nikic/php-parser v4.6.0 A PHP parser written in PHP
paragonie/constant_time_encoding v2.3.0 Constant-time Implementations of RFC 4648 Encoding (Base-64, Base-3...
paragonie/random_compat v9.99.99 PHP 5.x polyfill for random_bytes() and random_int() from PHP 7
php-http/client-common 2.3.0 Common HTTP Client implementations and tools for HTTPlug
php-http/discovery 1.9.1 Finds installed HTTPlug implementations and PSR-7 message factories
php-http/guzzle6-adapter v2.0.1 Guzzle 6 HTTP Adapter
php-http/httplug 2.2.0 HTTPlug, the HTTP client abstraction for PHP
php-http/message 1.8.0 HTTP Message related tools
php-http/message-factory v1.0.2 Factory interfaces for PSR-7 HTTP Message
php-http/promise 1.1.0 Promise used for asynchronous HTTP requests
phpdocumentor/reflection-common 2.2.0 Common reflection classes used by phpdocumentor to reflect the code...
phpdocumentor/reflection-docblock 5.2.0 With this component, a library can provide support for annotations ...
phpdocumentor/type-resolver 1.3.0 A PSR-5 based resolver of Class names, Types and Structural Element...
phpspec/prophecy v1.10.3 Highly opinionated mocking framework for PHP 5.3+
phptek/sentry 3.0.4 Sentry.io integration for SilverStripe. Binds Sentry.io to SilverSt...
phpunit/php-code-coverage 4.0.8 Library that provides collection, processing, and rendering functio...
phpunit/php-file-iterator 1.4.5 FilterIterator implementation that filters files based on a list of...
phpunit/php-text-template 1.2.1 Simple template engine.
phpunit/php-timer 1.0.9 Utility class for timing
phpunit/php-token-stream 2.0.2 Wrapper around PHP's tokenizer extension.
phpunit/phpunit 5.7.27 The PHP Unit Testing framework.
phpunit/phpunit-mock-objects 3.4.4 Mock Object library for PHPUnit
psr/cache 1.0.1 Common interface for caching libraries
psr/container 1.0.0 Common Container Interface (PHP FIG PSR-11)
psr/http-client 1.0.1 Common interface for HTTP clients
psr/http-factory 1.0.1 Common interfaces for PSR-7 HTTP message factories
psr/http-message 1.0.1 Common interface for HTTP messages
psr/log 1.1.3 Common interface for logging libraries
psr/simple-cache 1.0.1 Common interfaces for simple caching
ptcinc/solr-php-client v1.0.0 A purely PHP library for indexing and searching documents against a...
ralouphie/getallheaders 3.0.3 A polyfill for getallheaders.
sebastian/code-unit-reverse-lookup 1.0.1 Looks up which function or method a line of code belongs to
sebastian/comparator 1.2.4 Provides the functionality to compare PHP values for equality
sebastian/diff 1.4.3 Diff implementation
sebastian/environment 2.0.0 Provides functionality to handle HHVM/PHP environments
sebastian/exporter 2.0.0 Provides the functionality to export PHP variables for visualization
sebastian/global-state 1.1.1 Snapshotting of global state
sebastian/object-enumerator 2.0.1 Traverses array structures and object graphs to enumerate all refer...
sebastian/recursion-context 2.0.0 Provides functionality to recursively process PHP variables
sebastian/resource-operations 1.0.0 Provides a list of PHP built-in functions that operate on resources
sebastian/version 2.0.1 Library that helps with managing the version number of Git-hosted P...
sentry/sdk 2.1.0 This is a metapackage shipping sentry/sentry with a recommended htt...
sentry/sentry 2.4.1 A PHP SDK for Sentry (http://sentry.io)
sheadawson/silverstripe-dependentdropdownfield 2.0.3 A silverstripe dropdown field that has it's options populated via a...
silverstripe/admin 1.6.0 SilverStripe admin interface
silverstripe/akismet 4.0.4 Akismet antispam module for Silverstripe
silverstripe/asset-admin 1.6.0 Asset management for the SilverStripe CMS
silverstripe/assets 1.6.0 SilverStripe Assets component
silverstripe/auditor 2.2.1 Adds security audit trail to SilverStripe.
silverstripe/blog 3.5.1 A fresh take on blogging in Silverstripe set out to tackle the issu...
silverstripe/campaign-admin 1.6.0 SilverStripe campaign admin interface
silverstripe/cms 4.6.0 The SilverStripe Content Management System
silverstripe/comment-notifications 2.0.1 Provides email notifications for visitor comments
silverstripe/comments 3.3.1 This module provides commenting functionality for Pages and other D...
silverstripe/config 1.0.18 SilverStripe configuration based on YAML and class statics
silverstripe/content-widget 2.1.0 Display HTML content in a widget
silverstripe/environmentcheck 2.2.0 Provides an API for building environment tests
silverstripe/errorpage 1.6.0 ErrorPage component for SilverStripe CMS
silverstripe/framework 4.6.0 The SilverStripe framework
silverstripe/fulltextsearch 3.7.0 Adds support for Fulltext Search engines like Sphinx and Solr to Si...
silverstripe/graphql 3.3.0 GraphQL server for SilverStripe models and other data
silverstripe/html5 2.0.1 HTML5 support for SilverStripe
silverstripe/hybridsessions 2.2.0 Cookie/DB session support for SilverStripe
silverstripe/login-forms 4.2.0 A collection of templates for the CMS login screens
silverstripe/lumberjack 2.0.2 A module to make managing pages in a GridField easy without losing ...
silverstripe/mfa 4.1.0 Enable multi-factor authentication with fallback codes
silverstripe/mimevalidator 2.0.0 Checks uploaded file content roughly matches a known MIME type for ...
silverstripe/recipe-blog 1.6.0 SilverStripe Blog Project Template
silverstripe/recipe-cms 4.6.0 SilverStripe recipe for fully featured page and asset content editing
silverstripe/recipe-core 4.6.0 SilverStripe framework-only core recipe
silverstripe/recipe-plugin 1.3.0 Helper plugin to install SilverStripe recipes
silverstripe/reports 4.6.0 Reports module for SilverStripe CMS
silverstripe/security-extensions 4.0.2 A temporary polyfill repository for security improvements that will...
silverstripe/segment-field 2.2.3 A reusable approach to segment-generating fields
silverstripe/siteconfig 4.6.0 Site wide settings administration.
silverstripe/spamprotection 3.0.2 Spam protection module for SilverStripe.
silverstripe/tagfield 2.4.2 Tag field for SilverStripe
silverstripe/taxonomy 2.1.0 Provide extra taxonomy for cataloguing the data.
silverstripe/totp-authenticator 4.0.0 A TOTP authenticator for use with silverstripe/mfa
silverstripe/userforms 5.6.0 UserForms enables CMS users to create dynamic forms via a drag and ...
silverstripe/vendor-plugin 1.4.1 Allows vendor modules to expose directories to the webroot
silverstripe/versioned 1.6.0 SilverStripe Versioned component
silverstripe/versioned-admin 1.6.0 SilverStripe versioned admin interface
silverstripe/widgets 2.0.2 Widgets are small pieces of functionality such as showing the lates...
spomky-labs/otphp v9.1.4 A PHP library for generating one time passwords according to RFC 42...
squizlabs/php_codesniffer 3.5.5 PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects...
swiftmailer/swiftmailer v5.4.12 Swiftmailer, free feature-rich PHP mailer
symbiote/silverstripe-gridfieldextensions 3.2.2 A collection of useful grid field components
symbiote/silverstripe-queuedjobs 4.6.0 A framework for defining and running background jobs in a queued ma...
symfony/cache v3.4.42 Symfony Cache component with PSR-6, PSR-16, and tags
symfony/config v3.4.42 Symfony Config Component
symfony/deprecation-contracts v2.1.3 A generic function and convention to trigger deprecation notices
symfony/filesystem v4.4.10 Symfony Filesystem Component
symfony/finder v3.4.42 Symfony Finder Component
symfony/options-resolver v5.1.2 Symfony OptionsResolver Component
symfony/polyfill-apcu v1.18.0 Symfony polyfill backporting apcu_* functions to lower PHP versions
symfony/polyfill-ctype v1.18.0 Symfony polyfill for ctype functions
symfony/polyfill-intl-idn v1.18.0 Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions
symfony/polyfill-intl-normalizer v1.18.0 Symfony polyfill for intl's Normalizer class and related functions
symfony/polyfill-mbstring v1.18.0 Symfony polyfill for the Mbstring extension
symfony/polyfill-php56 v1.18.0 Symfony polyfill backporting some PHP 5.6+ features to lower PHP ve...
symfony/polyfill-php70 v1.18.0 Symfony polyfill backporting some PHP 7.0+ features to lower PHP ve...
symfony/polyfill-php72 v1.18.0 Symfony polyfill backporting some PHP 7.2+ features to lower PHP ve...
symfony/polyfill-php80 v1.18.0 Symfony polyfill backporting some PHP 8.0+ features to lower PHP ve...
symfony/polyfill-util v1.18.0 Symfony utilities for portability of PHP codes
symfony/polyfill-uuid v1.18.0 Symfony polyfill for uuid functions
symfony/process v3.4.42 Symfony Process Component
symfony/translation v2.8.52 Symfony Translation Component
symfony/yaml v3.4.42 Symfony Yaml Component
tijsverkoyen/akismet 1.1.0 Akismet is a wrapper-class to communicate with the Akismet API.
tractorcow/classproxy 0.1.2
tractorcow/silverstripe-proxy-db 0.1.0
unclecheese/display-logic 2.0.3 Allows assignment of conditions for display and hide of specific fo...
webmozart/assert 1.9.1 Assertions to validate method input/output with nice error messages.
webonyx/graphql-php v0.12.6 A PHP port of GraphQL reference implementation
willdurand/geocoder v3.3.0 The almost missing Geocoder PHP 5.4 library.
zendframework/zend-diactoros 1.8.7 PSR HTTP Message implementations
I will rebuild my local environment using the latest php tag, as it is now 7.3.19 and report after. A possibly relevant note is that I rolled back silverstripe to 4.5.1 in order to be able to work with sspak.
On php 7.3.20 I get the same behaviour
root@bf7ed3ed8814:/var/www# sspak load [dump-file].sspak
[23-Jul-2020 04:54:17 UTC] PHP Fatal error: Uncaught LogicException: You must call one of in() or append() methods before iterating over a Finder. in /var/www/vendor/symfony/finder/Finder.php:569
Stack trace:
#0 /var/www/vendor/silverstripe/config/src/Transformer/YamlTransformer.php(78): Symfony\Component\Finder\Finder->getIterator()
#1 /var/www/vendor/silverstripe/config/src/Transformer/YamlTransformer.php(90): SilverStripe\Config\Transformer\YamlTransformer->__construct('/var/www', Object(Symfony\Component\Finder\Finder))
#2 /var/www/vendor/silverstripe/framework/src/Core/Config/CoreConfigFactory.php(140): SilverStripe\Config\Transformer\YamlTransformer::create('/var/www', Object(Symfony\Component\Finder\Finder))
#3 /var/www/vendor/silverstripe/framework/src/Core/Config/CoreConfigFactory.php(113): SilverStripe\Core\Config\CoreConfigFactory->buildYamlTransformerForPath(Array)
#4 /var/www/vendor/silverstripe/framework/src/Core/Config/CoreConfigFactory.php(91): SilverStripe\Core\Config\CoreConfigFactory->buildYamlTransformer()
#5 /var/www/vendor/silvers in /var/www/vendor/symfony/finder/Finder.php on line 569
Command: /usr/bin/env 'php' '/tmp/sspak-sniffer-111020.php' '.'
Execution failed: returned 255.
Output:
Fatal error: Uncaught LogicException: You must call one of in() or append() methods before iterating over a Finder. in /var/www/vendor/symfony/finder/Finder.php:569
Stack trace:
#0 /var/www/vendor/silverstripe/config/src/Transformer/YamlTransformer.php(78): Symfony\Component\Finder\Finder->getIterator()
#1 /var/www/vendor/silverstripe/config/src/Transformer/YamlTransformer.php(90): SilverStripe\Config\Transformer\YamlTransformer->__construct('/var/www', Object(Symfony\Component\Finder\Finder))
#2 /var/www/vendor/silverstripe/framework/src/Core/Config/CoreConfigFactory.php(140): SilverStripe\Config\Transformer\YamlTransformer::create('/var/www', Object(Symfony\Component\Finder\Finder))
#3 /var/www/vendor/silverstripe/framework/src/Core/Config/CoreConfigFactory.php(113): SilverStripe\Core\Config\CoreConfigFactory->buildYamlTransformerForPath(Array)
#4 /var/www/vendor/silverstripe/framework/src/Core/Config/CoreConfigFactory.php(91): SilverStripe\Core\Config\CoreConfigFactory->buildYamlTransformer()
#5 /var/www/vendor/silvers in /var/www/vendor/symfony/finder/Finder.php on line 569
root@bf7ed3ed8814:/var/www# php -v
PHP 7.3.20 (cli) (built: Jul 22 2020 10:03:35) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.20, Copyright (c) 1998-2018 Zend Technologies
@halles Interesting - you're also on PHP 7.3.x - confirms my suspicion... can you also confirm, that it works if you flush per CLI before running sspak
? Like:
./vendor/bin/sake 'dev/build?flush'
I have managed to consistently reproduce the behaviour on php 7.3 and 7.4.
The error happens when the application has not yet been built. What I understand so far is that DatabaseAdapterRegistry is not loaded and is not available to be loaded until then.
I have replicated this issue on php 7.1 and php 7.3
It did require me to delete the entire silverstripe cache folder, in the case of vagrant it was
rm -rf /tmp/silverstripe-cache-php7.3.6-1+0-20190531112546.39+jessie-1.gbp6131b7-var-www-mysite-www/
I then ran '/dev/build' (without flush) via apache and it replicated the error
Running '/dev/build?flush' via apache made the error go away
While I was in state that replicated the error, I tried commenting some out the lines DatabaseAdapterRegistry.php that were changed in 4.6
This made the error go away. The particular line that triggers the error is $cache = static::getCache()
public static function getCache(): CacheInterface
{
return Injector::inst()->get(CacheInterface::class . '.DatabaseAdapterRegistry');
}
@emteknetnz I dug in for a bit over the weekend and what I could find is that this line eventually attempts getting available registered modules from the cache directory, but since there's nothing in there before a build, the directories where the injector gets stuff from are empty, which ends up triggering the displayed error above.
Obviously php-version isn't the problem.. since the ReflectionMethods in the sspak-sniffer cannot handle building the cache it may should flush if no manifest is there?
Even if you work around the immediate problem with symfony/finder
(I tried avoiding adding the YAML transformer if no directories were found), you encounter:
Uncaught SilverStripe\Core\Injector\InjectorNotFoundException: ReflectionException: Class Psr\SimpleCa
che\CacheInterface.DatabaseAdapterRegistry does not exist
This is starting to look a bit like a chicken-and-egg problem. Perhaps we could wrap the new caching code in a try/catch block? The following seems to work in my testing:
protected static function getConfigureDatabasePaths(): array
{
try {
// autoconfigure() will get called before flush() on ?flush, so manually flush just to ensure no weirdness
if (isset($_GET['flush'])) {
static::flush();
}
$cache = static::getCache();
$key = __FUNCTION__;
if ($cache->has($key)) {
return (array)$cache->get($key);
}
$paths = glob(BASE_PATH . '/vendor/*/*/_configure_database.php');
$cache->set($key, $paths);
return $paths;
} catch (Exception $e) {
return glob(BASE_PATH . '/vendor/*/*/_configure_database.php');
}
}
@kinglozzer ideally we'd do this without the try/catch just because it kind of hides the bug rather than dealing with it, though I'm also kind of fine with it the way you have it
if (isset($_GET['flush'])) {
This is possibly part of the problem. This will work with apache but not with doing flush via CLI. Do you happen to know what the "correct" way to detect if a flush is happening is? If so, would you by able to replace out the isset($_GET['flush'])
with that and see if that resolves the issue?
@emteknetnz Yeah it does suck, I’m not sure there’s any way around it though. Even if we make the “flush” check something like isset($_GET['flush']) || Director::is_cli()
, it still won’t work because the config manifest is empty at that point, so getCache()
can never manage to create a cache instance with Injector.
Another possible solution could be to add bootManifests
to the list of methods we invoke here: https://github.com/silverstripe/sspak/blob/7d58445c2f474762c3bff2ca57c3699641c52018/src/sspak-sniffer.php#L35-L41 I’m not sure about that though, it seems excessive to create a config manifest just for this when we don’t actually need one just to sniff database credentials.
We could trying making the cache use ManifestCacheFactory
which doesn’t depend on the config manifest, but we’d be making the logic around caching more complex (and we’d still have to rely on injector for Injector::inst()->get(Kernel::class)->isFlushed()
, so it’s still a little brittle).
I think wrapping the cache logic in a try/catch is acceptable, given how early in the request lifecycle DatabaseAdapterRegistry
is called, and that the caching here is a (relatively) minor performance enhancement. We’re hoping to remove that functionality entirely in 5.x, so I don’t mind making it a little “ugly” in the mean time
Fixed in https://github.com/silverstripe/silverstripe-framework/pull/9627
@kinglozzer I used your suggestion in the PR, though moved the try catch to just around the static::getCache()
call since that's what was causing the issue
Re these ACs:
Confirm or deny if the $_GET['flush] on the code on earlier fix (see comment below) is required, and if CLI dev/build (with and without flush) stuff flushes the cache. Either update code or write a comment explaining usage of $_GET['flush] (possible that it's there so that things flush in a particuar order)
$_GET['flush]
is required, the screenshot I took which this AC was based on missed the inline comment right above it explaining why it's needed =)
Confirm or deny if there's a wider issues where there's a difference between /dev/build and /dev/build?flush, and if so, raise a new issue
I couldn't find an issue, seems fine as is
The linked PR has been merged, this will be released with silverstripe/framework 4.6.2. Closing this issue now
Local like a local (webroot) - the dot in the middle
./vendor/bin/sspak save . ./test.sspak
The sniffer script started to fail with: https://github.com/silverstripe/silverstripe-framework/commit/e08bf1cdd96ea2930b2a41162eaad384404c1672if
DatabaseAdapterRegistry::autoconfigure($databaseConfig);
is commented out, it runs trough https://github.com/silverstripe/silverstripe-framework/blob/4/src/Core/CoreKernel.php#L372 otherwise it has a hard time getting the cache https://github.com/silverstripe/silverstripe-framework/blob/4/src/Dev/Install/DatabaseAdapterRegistry.php#L184@emteknetnz - I have difficulties understanding how it fails. May you can shed some light on it?
ACs
$_GET['flush]
on the code on earlier fix (see comment below) is required, and if CLI dev/build (with and without flush) stuff flushes the cache. Either update code or write a comment explaining usage of$_GET['flush]
(possible that it's there so that things flush in a particuar order)