rockettheme / toolbox Goto Github PK
View Code? Open in Web Editor NEWRocketTheme\Toolbox package contains a set of reusable PHP interfaces, classes and traits.
License: MIT License
RocketTheme\Toolbox package contains a set of reusable PHP interfaces, classes and traits.
License: MIT License
I get this error in Grav on php 8.2:
Creation of dynamic property RocketTheme\Toolbox\StreamWrapper\ReadOnlyStream::$context is deprecated, any idea on fixing this?
I've been playing around with UniformResourceLocator
more, and I'm trying to use it to resolve user-supplied paths. However, the way I'm using it now opens me up to a directory traversal attack:
$locator = new UniformResourceLocator('/path/to/document/root');
// Adds 'assets' to the searchable paths
$locator->addPath('assets', '', 'assets');
// Initialize streams
ReadOnlyStream::setLocator($locator);
$sb = new StreamBuilder([
'assets' => '\\RocketTheme\\Toolbox\\StreamWrapper\\ReadOnlyStream'
]);
$url = "assets://../secret.txt";
echo file_get_contents($locator->findResource($url));
// prints contents of '/path/to/document/root/assets/../secret.txt'
Is there, or should there be, an option to prevent the locator from resolving paths outside of one of the designated directories?
include(): RocketTheme\Toolbox\StreamWrapper\Stream::stream_set_option is not implemented!
Since PHP 7.4, stream_set_option
implementation is required :
When using include/require on a stream, streamWrapper::stream_set_option() will be invoked with the STREAM_OPTION_READ_BUFFER option. Custom stream wrapper implementations may need to implement the streamWrapper::stream_set_option() method to avoid a warning (always returning FALSE is a sufficient implementation).
https://www.php.net/manual/en/migration74.incompatible.php
I could submit a PR if someone points me to an example implementation for stream_set_option
.
Hi, curently it's not possible to install this package due to dependencies problems.
rockettheme/toolbox 1.2.1 requires symfony/event-dispatcher ~2.5 -> satisfiable by symfony/symfony[v2.8.2], symfony/event-dispatcher[v2.5.0, v2.5.1, v2.5.10, v2.5.11, v2.5.12, v2.5.2, v2.5.3, v2.5.4, v2.5.5, v2.5.6, v2.5.7, v2.5.8, v2.5.9, v2.6.0, v2.6.1, v2.6.10, v2.6.11, v2.6.12, v2.6.13, v2.6.2, v2.6.3, v2.6.4, v2.6.5, v2.6.6, v2.6.7, v2.6.8, v2.6.9, v2.7.0, v2.7.1, v2.7.2, v2.7.3, v2.7.4, v2.7.5, v2.7.6, v2.7.7, v2.7.8, v2.7.9, v2.8.0, v2.8.1, v2.8.2].
- Can only install one of: symfony/symfony[v3.0.0, v2.8.2].
- don't install symfony/event-dispatcher v2.5.0|don't install symfony/symfony v3.0.0
Regards
Blueprint override system is not that simple.
When a file is located in the wrong directory, wrong directory structure, or with an extension mismatch like .yml
instead of .yaml
, then import@
is simply ignored.
In -dev mode this is frustrating: an error message about locations searched for or at the very least a warning about import failure would really help.
thank you
Right now all calls for @import
insert the new fields into the top of the form.
Figure out a way to be able to insert fields also to the end of the form or between existing fields.
Support multiple imports in the same place:
import@1: fields/hero
import@2: fields/footer
Add support for partial imports:
# Same as without specifying partial import:
import@1: fields/hero:form
# Imports hero section separator:
import@2: fields/hero:form/fields/hero
# Imports fields outside of the main form:
import@3: fields/footer:test/fields
# Imports also work from the current file:
import@4: :include/fields
It would be useful to have an $absolute flag for getPaths
. Otherwise, I have to call getBase
, and then loop through getPaths
to manually prepend the base. I could do a PR for this, if anyone is interested.
Hello!
(I'm not sure if this is the right forum, please if it is not - tell me the right one and you do not hate me! ;) )
In general, the site is not very good and mobile friendly and should be worked on, but for now I would be happy if someone help me with the solution of this problem here (see the title menu and logo at example) www.sgemsocial.org ! The parts overlap when is going to mobile version ... how I should solve this problem? ...how would you resolve it? Is exist also on other cases on this site!
Thank you and greetings everyone!
I'm trying to extends
a form and tend to think that documentation is sparse.
extends
and import
deserve much more than what provides these two documentation sections.
Even the parent@
is a bit hard to catch with. Where is the inheritance defined?
Digging the sourcecode does help as expected. For example blueprints documentation at https://learn.getgrav.org/forms/blueprints is not sufficient to understand BlueprintForm.php
,
An overview of the (YAML) functions available, the file path they are looking for, the contexts where they can be used and the YAML structures merge strategies, the level at which they can be used would really help in order to use these constructs at there full value.
Eg: can I import a form:
? its ""items""
? rules
included? or only its fields:
and what about extends
?
Hello again!
( And again, I'm not sure if this is the right forum, please if it is not - tell me the right one and you do not hate me! ;) )
And another case from me! ( our unattractive site - www.sgemsocial.org ) Lately, i have problems with RokSprocket Modules that simple are not working when the web site is online, and work very well on the local host! the parameters and options of the site are identical, I compared them many times!
Greetings to everyone here!
findResource
seems to have trouble resolving URIs that contain query parameters. For example, this seems to work fine:
$locator = new UniformResourceLocator(MY_BASE_DIR);
$locator->addPath('assets', '', 'assets');
echo $locator->findResource('images/favicon.ico', false);
// prints "assets/images/favicon.ico"
However if I do this:
$locator = new UniformResourceLocator(MY_BASE_DIR);
$locator->addPath('assets', '', 'assets');
echo $locator->findResource('images/favicon.ico?v=2', false);
// prints the empty string
Not sure if this is the intended behavior.
The concept of blueprints
expressed in the documentation seems very related to YAML inheritance, and most of BlueprintForm.php
intents are related to this.
The form-plugin
-> grav built-in blueprints
-> toolbox form blueprints
loading/importing, the closure magics and sparse documentation (aside from some phpdoc of little help) makes this part of the codebase huge, complex and really hard to understand.
I'm new to Grav codebase but I wonder whether YAML builtins would be a better fit
## pages/01.home/form.md
## Over-exagerated example
!include blueprint://my-form as my_form # using an alias notation
!include plugin://foo/common-rules.yml # or importing in a namespace derived from path
rules:
<<: *my_form.rules
<<: *plugins.foo.common_rules
form: *my_form.form
## plugins/foo/common-rules.yml
common_rules:
blah: foo
If the main goal is to provide an easy YAML inheritance system, YAML already provides:
&anchor
*reference
<<: *merge
<<: *merge{partial: key}
!include
macro directiveThese provides a much more explicit and flexible way to define inheritance relationships inside YAML.
Some examples of YAML preprocessors:
Latest version release add Symfony 5 in composer.json
:
1.6.0...1.6.1#diff-d2ab9925cad7eac58e0ff4cc0d251a937ecf49e4b6bf57f8b95aab76648a9d34R13
First, this a breaking change as it can cause unwanted dependencies change in some cases, and should have done in a new major version.
That being said, EventDispatcher doesn’t seams to be compatible with latest Symfony version :
PHP Fatal error: Declaration of RocketTheme\Toolbox\Event\EventDispatcher::dispatch($eventName, ?Symfony\Component\EventDispatcher\Event $event = null) must be compatible with Symfony\Component\EventDispatcher\EventDispatcher::dispatch(obj
ect $event, ?string $eventName = null): object in <SNIP>\UserFrosting-4.6.3\app\vendor\rockettheme\toolbox\Event\src\EventDispatcher.php on line 23
Fatal error: Declaration of RocketTheme\Toolbox\Event\EventDispatcher::dispatch($eventName, ?Symfony\Component\EventDispatcher\Event $event = null) must be compatible with Symfony\Component\EventDispatcher\EventDispatcher::dispatch(object $
event, ?string $eventName = null): object in <SNIP>\UserFrosting-4.6.3\app\vendor\rockettheme\toolbox\Event\src\EventDispatcher.php on line 23
After a fresh install (git clone ... + composer install), PHPUnit produce some error on PHP 8.0 :
$ vendor/bin/phpunit
PHP Fatal error: Declaration of UniformResourceLocatorTest::setUpBeforeClass() must be compatible with PHPUnit\Framework\TestCase::setUpBeforeClass(): void in /Users/xxx/toolbox/ResourceLocator/tests/UniformResourceLocatorTest.php on line 15
Fatal error: Declaration of UniformResourceLocatorTest::setUpBeforeClass() must be compatible with PHPUnit\Framework\TestCase::setUpBeforeClass(): void in /Users/xxx/toolbox/ResourceLocator/tests/UniformResourceLocatorTest.php on line 15
Plus the Travis implementation doesn't work anymore : https://travis-ci.org/github/rockettheme/toolbox/
This is a big red flags, as CI doesn't works and testing is not properly ran with each new releases. I would suggest replacing Travis with GitHub action ASAP. It's not inviting to submit a pull request currently since we can't know if a change breaks something else.
I run Grav 1.6.8 on a Ubuntu 18.04 server with Apache 2.4.
After installing Grav and the Quark Open Publishing theme I get this error with any bin/gpm command:
PHP Fatal error: Uncaught RuntimeException: Failed to save file WEBROOT/cache/compiled/blueprints/master-localhost.php in WEBROOT/vendor/rockettheme/toolbox/File/src/File.php:351
Stack trace:
#0 WEBROOT/vendor/rockettheme/toolbox/File/src/PhpFile.php(31): RocketTheme\Toolbox\File\File->save(Array)
#1 WEBROOT/system/src/Grav/Common/Config/CompiledBase.php(252): RocketTheme\Toolbox\File\PhpFile->save(Array)
#2 WEBROOT/system/src/Grav/Common/Config/CompiledBase.php(117): Grav\Common\Config\CompiledBase->saveCompiledFile('/var/www/produs...')
#3 WEBROOT/system/src/Grav/Common/Service/ConfigServiceProvider.php(77): Grav\Common\Config\CompiledBase->load()
#4 WEBROOT/system/src/Grav/Common/Service/ConfigServiceProvider.php(36): Grav\Common\Service\ConfigServiceProvider::blueprints(Object(Grav\Common\Grav))
#5 /var/www/produsr1/foto.metadate in WEBROOT/vendor/rockettheme/toolbox/File/src/File.php on line 351
The WEBROOT/cache/compiled/blueprints
folder holds already a file saved while installing Grav. Owner of the folder is the usual www-data.
As this stops any further action using bin/gpm I can't use Grav at all.
In my Grav plugin Count Views, I'm using the RocketTheme\Toolbox\File\File
interface. The plugin works fine in *nix environments, but it doesn't work in Windows. (I've only tested under XAMPP. But I'm told it works under the Windows Subsystem for Linux.)
The problem is these lines here:
// Open data file
$datafh = File::instance($path);
$datafh->lock();
$data = Yaml::parse($datafh->content());
if ($data === null) {
$data = array();
}
No matter what, $datafh->content()
is returning null on Windows, even though it loaded the file fine on lines 63-66. The only difference is the file locking.
I added an if/then, and indeed the file is getting locked. And I can confirm that if I remove the lock()
line, everything works as expected.
Any help appreciated. Thanks!
... because
toolbox/Blueprints/src/BlueprintForm.php
Line 438 in 8ad2b96
$order
from being set if the location is 0
because the conditional does not distinguish between 0
and the empty string.When an import@ is processed, eg like:
form:
import@:
type: partials/form-foo
context: blueprints://
the form
key is extracted and only fields are merged.
So there is no way to avoid repeating rules
and form parameters
instead of import
ing them.
Side note: the blueprints import/extends codebase is tremendously hard to catch up.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.