silverstripe / developer-docs Goto Github PK
View Code? Open in Web Editor NEWDeveloper documentation for Silverstripe CMS
License: Other
Developer documentation for Silverstripe CMS
License: Other
I started out listing breaking changes in the update docs (with the intention that it would be used to create a more how-to style document later on), and then ended up putting a more how-to write up in the changelogs because that's the kind of content we normally add there - because we normally aren't doing major releases.
I think we should be listing the explicit breaking changes (removed x, use y instead) in the changelog, and then anything that requires further explanation should be in the upgrade docs.
This issue exists both to facilitate discussion about that in case anyone disagrees, and then to actually set up the docs in whichever manner is agreed upon.
SS 4.3
Cannot add i18 javascript using ModuleResourceLoader::resourceURL()
I try to add
Requirements::add_i18n_javascript(
ModuleResourceLoader::resourceURL('dnadesign/silverstripe-elemental:lang')
);
resourceURL()
returns /resources/vendor/dnadesign/silverstripe-elemental/lang
This is treated as absolute path in Director::getAbsFile
, therefor the lang file isn't loaded cause the file isn't found.
A lot of the examples on these two articles need to be updated to account for the fact that our classes are namespaced now.
https://docs.silverstripe.org/en/4/developer_guides/i18n/
https://docs.silverstripe.org/en/4/developer_guides/templates/translations/
<%t Member.WELCOME 'Welcome {name} to {site}' name=$Member.Name site="Foobar.com" %>
_t('LeftAndMain.FILESIMAGES','Files & Images');
en:
ImageUploader:
Attach: 'Attach {title}'
UploadField:
NOTEADDFILES: 'You can add files once you have saved for the first time.'
There are lots of links in the documentation that use absolute URLs to other documentation where a relative URL should be used. This will be a problem when migrating docs to a new major release branch, where they will then be pointing to documentation for the wrong major.
There are also absolute URLs for links to API (https://api.silverstripe.org/4/Some/Class.html
) which should use the (Some\Class)[api:Some\Class]
syntax.
Looking at the Making a SilverStripe core release, it's horribly out of date.
For the most part we are going off internal documentation that we haven't shared with the wider public.
The internal release doc would not make much sense as is without some guidance from a CMS Squad member.
I'm thinking either we scrap this entire doc article or we update it to be more generic so people have a general overview of what we do when we do a release.
4.10
The functional test docs suggest that $this->assertPartialHTMLMatchBySelector
will test the element content, but the code actually tests against the outerHTML.
That is to say, the example code in the docs will always fail
$this->assertPartialHTMLMatchBySelector("#MyForm_ID p.error", [
"That email address is invalid."
]);
it would need to be changed to something like this if we expect it to ever work
$this->assertPartialHTMLMatchBySelector("#MyForm_ID p.error", [
"<p class=\"error\">That email address is invalid.</p>"
]);
In my case the result I'm getting is
$this->assertPartialHTMLMatchBySelector('#SaleAdEditForm_getForm_Create_your_account', ['Create your account']);
1) SaleAdEditorPageTest::testCreateAccountWithListing
Failed asserting the CSS selector '#SaleAdEditForm_getForm_Create_your_account' has a partial match to the expected elements:
'Create your account'
Instead the following elements were found:
'<h2 id="SaleAdEditForm_getForm_Create_your_account">Create your account</h2>'
Failed asserting that false is true.
N/A
Currently we support scaffolding forms in JavaScript in modules like asset-admin
and elemental
. Currently for developers it's not clear at a glance which fields are actually supported. For instance we know that GridField
is not supported and ListBoxField
is partially supported.
We should add some docs to help developers understand the current support/limitations of the JS form scaffolding functionality.
Our front-end documentation is fractured, outdated, and in some cases potentially misleading. It could do with a review.
4.4
4.1.0 bought in the new $public
theme set and I’m finding that the suggested theme order in the change log (https://docs.silverstripe.org/en/4/changelogs/4.1.0/#public-theme) is causing some template inheritance issues when a module is overriding a template that I’m also overriding in my theme.
themes:
- '$public'
- 'mytheme'
- '$default'
For example https://github.com/unclecheese/silverstripe-display-logic overrides the SilverStripe\Forms\OptionsetField
template and I’m also overriding that in my theme. If I put my theme at the top of the list that gets around it but I'm unsure after reading the docs whether that is going to cause any issues. I don’t use the likes of the themedCSS
methods so perhaps it doesn’t really matter?
This may even be expected behaviour but thought i'd log anyway for clarity.
Our doc provide a Security page with a dump of best practices. That page is not very readable.
It probably would help to review that page with an eye towards updating the list. We should also aim to separate advice about generic server set up and coding best practices.
We could also aim to structure the list of steps as a "Cheat Sheet" that people can easily reference.
Also relevant is the grahql security and best practices doc
When I first started using Silverstripe and got any sort of saving/canView errors in the CMS in my own code, I had no idea that I could open the Google Chrome/Firefox developer tools and check the network tab to read the errors, and so I used to always try and quickly retrieve the error before it 'faded away'.
If we want to build a bigger community we need to think about the people that are just dipping their toes into web development too.
https://docs.silverstripe.org/en/3.3/developer_guides/debugging/
Injector docs are improved and easier to maintained.
Documentation site
On the documentation site, the Access Control page doesn't contain a lot of useful information, and reads more like a stream of consciousness while someone was reading the code, rather than a useful developer guide. The whole page has this sort of content, but the 'Permission checking is at class level' section is probably the worst offender.
The page should ideally be re-written to properly cover the Access Control model that SilverStripe implements.
I'll try to do this in a PR, but no guarantees - adding this issue in case I don't get a chance to re-write it.
If you call limit
on a DataList
, and then call filterByCallback
, the data query will first be executed, which gets a limited number of results from the database. This limited result set is then filtered using the callback, which may result in even less results being returned.
This was pointed out by @christopherdarling in the below comment, which perhaps explains it a little more clearly:
that's true but this does unearth the issue of the order you call these methods for example;
- if you do
Page::get()->filterByCallback(fn () => true)->limit(10)->count();
,filterByCallback()
loops over the entire set of Page rows (possibly 1000's) to do the filter comparison even after the 10th valid item is found which isn't necessary. I think this code change avoids that- if you do
Page::get()->limit(10)->filterByCallback(fn ($item) => $item->URLSegment !== 'home')->count();
I get 9 records because we're filtering on the 10 records from the database and 1 fails this filter- if you do
Page::get()->reverse()->limit(10)->filterByCallback(fn ($item) => $item->URLSegment !== 'home')->count();
I get 10 records (where the filter doesn't remove any rows)
Originally posted by @christopherdarling in silverstripe/silverstripe-framework#10248 (comment)
There are several sections in the docs outside the explicit graphql section that refer to graphql, e.g. https://docs.silverstripe.org/en/4/developer_guides/model/versioning/#expose-graphql-scaffolding
These currently are written with graphql 3 compatability. They should be updated for graphql 4 compatability.
Once these are all merged, reassign to me so I can update the CMS 5 docs
Once these are all merged, reassign to me so I can update the CMS 5 docs and code if necessary
The Making a core release docs don't spell out how to handle new minor release branches (e.g. branching off 4
to 4.4
), and how that affects branch aliases in recipes/installer, as well as the dependencies in those.
Option A: Set recipes/installer constraints on major release branch (e.g. 4
) to the branch-alias. Example: silverstripe/installer:4.x-dev
requires silverstripe/recipe-cms:4.5.x-dev
Option B: Set recipes/installer constraints on major release branch (e.g. 4
) to the major release branch of the dependency. Example: silverstripe/installer:4.x-dev
requires silverstripe/recipe-cms:4.x-dev
We're effectively doing Option A everywhere already, but there's been some confusion between @robbieaverill @ScopeyNZ and myself around this (see silverstripe/silverstripe-installer@cfba4cb and silverstripe/silverstripe-installer@3e7294e).
I'm proposing that we're keeping Option A, but documenting this better.
The CWP release instructions on https://silverstripe.atlassian.net/wiki/spaces/CWP/pages/655458662/Instructions+for+CWP+release already reflect this (see point 3.1)
Currently when the 5 branch gets new content merged in, we have to manually deploy the changes.
The workflow should be updated to deploy when the 5 branch gets pushes.
5
branch, the site is deployedThe docs for setUp
and tearDown
in SapphireTest
are incorrect as these methods are protected
now.
Additionally the docs have a section about using setUpBeforeClass
in your tests:
https://github.com/silverstripe/silverstripe-framework/blame/4/docs/en/02_Developer_Guides/06_Testing/00_Unit_Testing.md#L140 (blame because there's no line-number view for markdown files 😞 )
This doesn't mention any of the caveats of using this like certain scaffolding not being ready yet - the example from community Slack being you can't Security::setCurrentUser
. Personally I would generally discourage use of it in most cases as test state should not persist between individual tests.
Either way that section could be improved to warn developers better.
All.
The markdown docs for many SilverStripe GH projects could be even more useful for anal retentives such as myself who cannot make sense of a block of text, unless they've first removed typ0s, grammer, punctuasion's and markdoon` errors from his or her text! :-)
This issue serves as a placeholder for an example of an "easy" issue to be achieved by students of the SilverStripe group of the 2019 Catalyst Open Source Academy intake, and restricted to the "silverstripe/framework" package in the first-instance.
Suggested tools:
Review the following random selection of docs for issues of this kind (There will be more, these are just those I found in the space of ~15m):
Currently most of the code examples in the docs do not include namespaces. This is a holdover from the SS3 days, and can in some cases result in a lack of clarity over whether namespaces should be included (e.g. most yaml config needs it but graphql for example doesn't always need namespaces).
We should add namespaces to all of the code examples so that it's clear how namespaces fit in with Silverstripe code.
Parent issue for #101
The problem
It's unclear on what is meant here (had a client literally ask us and pointed to the documentation)
The solution
Add parenthesis with something like "Configure at OS level".
I have a feeling there is more to cover here that I'm not across, but multiple examples of "first class" env vars would help!
Suggested copy change:
Sensitive credentials should not be stored in a VCS or project code and should only be stored on the environment in question. When using live environments the use of .env files is discouraged and instead one should use environment variables set at the OS level.
Source:
https://docs.silverstripe.org/en/4/getting_started/environment_management/#security-considerations
We don't currently have any automated checks to validate the quality of our documentation. This means we might potentially have now - or could easily introduce in the future - markdown formatting issues, incorrectly formatted links, etc. This is especially likely to happen with some of the custom markdown syntax such as API links.
text
for plain text blocks)api:Namespace\Class::someMethod()
syntax instead of a hardcoded links, links to other docs sections are relative)[info]
and similar are formatted correctly and are never left unclosed{#some-anchor}
in headings)yaml
or yml
but not both)namespace
declarations in php code examplesThis should be run on all PRs automatically via github actions.
NOTE: Linting should respect Silverstripe's writing style guide (only accessible to Silverstripe employees currently)
These will be done after the first lot of PRs are merged.
MD013
line-length rule, to limit lines to 120 characters.DO NOT CLOSE UNTIL ALL TODO ITEMS ARE COMPLETE
4.3.2 (and probably others)
If a controller method is prefixed with get
but called in a template without the prefix, arguments passed in the template are not passed to the method.
I'm not sure if this is strictly a bug as I couldn't find a lot of documentation about getters, but my understanding of the convention in SilverStripe is that getMethod()
is expected to work the same as Method()
.
Perhaps by convention getters shouldn't accept arguments but thought this was worth reporting anyhow. Surfaced by this forum post.
Page controller:
public function Foo() {
return 'Foo';
}
public function Bar($bar='Bar') {
return $bar;
}
Page template: $Foo $Bar(Foo)
Expected result: "Foo Foo"
Actual result: "Foo Foo" ✅
Page controller:
public function getFoo() {
return 'Foo';
}
public function getBar($bar='Bar') {
return $bar;
}
Page template: $Foo $Bar(Foo)
Expected result: "Foo Foo"
Actual result: "Foo Bar" ❌
Page controller:
public function getFoo() {
return 'Foo';
}
public function getBar($bar='Bar') {
return $bar;
}
Page template: $getFoo $getBar(Foo)
Expected result: "Foo Foo"
Actual result: "Foo Foo" ✅
The icon for the "Managing Security Issues" page does not display correctly
If it's a valid icon, we need to fix it in silverstripe/doc.silverstripe.org - otherwise we need to set a valid icon here in the docs
If you create a page type with a canDelete(...) return false; in it, it becomes impossible to delete an elemental on this page type. You have to override any elemental's canDelete(...) function in order to get it to work
See BaseElement.php line 251 in canDelete($member = null)
We've changed a lot of stuff in the 4.0 release around filesystem. It's been documented alongside feature pull requests, but it's mostly been focused on the new File
model abstraction. There's been lots of lower level changes that aren't documented in a coherent place, mainly around ModuleLoader
and ModuleManifest
APIs.
public/
and mysite/
directories, regardless of their context (building themes, building modules, working with files)$project
, how to configure it, how to use it to get custom paths. Both in Files > File Management and Configuration. Ensure that devs know that they can rename the mysite/
folder, and what effects that hasDirector::baseFolder()
and alternate_base_folder
in an obvious place (e.g. "Filesystem"). Can point to "Execution Pipeline" for details, but shouldn't require devs to find that document in the first place since it's much too advanced for this basic infoSilverStripe\Core\Path
There are multiple separate references to configuring file archiving via keep_archived_assets
I'm not sure how many of these you actually need to set to true
in order to get keep_archived_assets
to function correctly. Possibly some of these are previous implementations and no longer do anything. Seems like we should at have a single source of truth in the docs for how to enable this feature.
Undocumented:
https://github.com/silverstripe/silverstripe-assets/blob/1/src/AssetControlExtension.php#L47
private static $keep_archived_assets = false;
Documented:
SilverStripe\Assets\File:
keep_archived_assets: true
class MyVersiondObject extends DataObject
{
/** Ensure assets are archived along with the DataObject */
private static $keep_archived_assets = true;
SilverStripe\Assets\Flysystem\FlysystemAssetStore:
keep_archived_assets: true
In order to ensure effective contribution, I think we need to provide some guides on how to set up IDEs / editors for work on SilverStripe core.
Off the top of my head, we should address the following areas:
And based on https://groups.google.com/forum/#!topic/silverstripe-dev/bozY5hh9g4c, we should cover the following editors:
This information should probably be put alongside the other handy tips for contribution:
Some relevant Atom packages
4.4.*
see: https://docs.silverstripe.org/en/4/developer_guides/model/relations/
I wonder if we should include some information about ManyMany Through lists about having to create a unique index in the Through Table... e.g.
private static $indexes = [
'ManyManyUniqueKey' => [
'type' => 'unique',
'columns' => ['ClassID', 'YearID'],
],
];
n/a
<head>
or <body>
tags.CMSEditLink()
CMSEditLink()
anymoreframework v4.3.0 & v4.3.1 / PHP7.1
Attempting to use custom method output as Gridfield column content, fails when naming the key with "get", but only if the method is not empty. Empty strings for example will work A-OK. Renaming the key to omit "get" in `$summary_fields will also work A-OK.
Scenarios:
private static $summary_fields = [
'getFoo' => 'Bar',
'getBar' => 'Foo',
'FooBar' => 'Foo'
];
public function getFoo()
{
return ''; // <-- Empty string - works
}
public function getBar()
{
return ' '; // <-- Single space - FAIL
}
public function getFooBar()
{
return 'TEST TEST 1.2.3'; // <-- Anything here is OK. Method sig contains "get", but we leave it off the respective `$summary_fields` key
}
See code examples above.
There is a github action on this repository that should trigger on push to the 4.11
and 3
branch. This should include a push triggered by merging a PR.
There have been several PRs merged to the 4.11
branch, but https://github.com/silverstripe/developer-docs/actions/workflows/build.yml shows the action has never run.
4.11
or 3
branch, or docs are pushed directly to one of these branches, the github action triggers a deployment to docs.silverstripe.orghttps://docs.silverstripe.org/en/4/developer_guides/extending/modules/ and https://docs.silverstripe.org/en/4/developer_guides/extending/how_tos/publish_a_module/ don't describe how to actually create a module. With composer, there's a bit of a chicken-and-egg situation: You need to have a module to install it via composer on your site, get autoloading going, and then start developing.
Given that we want people to create modules for SilverStripe, this should be far more obvious.
Setting up your own webserver on a host system is no longer necessary, given the speed and usability improvements in virtualisation layers. Our main gettgin started guide in the docs still recommends installing on the host: https://docs.silverstripe.org/en/4/getting_started/installation/
The tutorials are a bit clearer (VMs as the first option), but could also be a bit clearer in their recommendation: https://www.silverstripe.org/learn/lessons/v4/up-and-running-setting-up-a-local-silverstripe-dev-environment-1.
We should provide a consistent and advice here, and clearly mark out "advanced use cases" to avoid confusing beginners. And not treat our guides as "related content", but rather have one way to install our product.
As a developer:
4 and above
Following some discussion it appears the "vendor expose" process is not super clear for most of the SilverStripe community.
I suggest we fix this by providing a central doc article demystifying the vendor-expose logic.
4.11
I recently ran Rector on my project and it's complaining about the use of $this->config. Indeed, the method definition is static, so why is it recommended to call $this->config instead of self::config or static::config ?
See docs here: https://docs.silverstripe.org/en/4/developer_guides/configuration/configuration/
We don't have clear guidance on how and when to deprecate method and classes.
@deprecated
phpdoc annotationDeprecation::notice()
@deprecated 4.1.0:5.0.0 Some description
. In this scenario, 4.1.0 would be the version where the method got deprecated and 5.0.0 would be the version where the method is expected to be remove. The second version parameter got dropped. But we still use that syntax in a few places.@deprecated
SS4+
It would be great to have a bit more detail for about setFieldCasting.
In particular, it is unclear which one we should use:
'MyField' => DBDatetime::class.'->Nice', //OR
'MyField' => 'Datetime->Nice', //OR
'MyField' => 'DBDatetime->Nice'
Documentation for caching states on line 133 that :
You can also set your lifetime to 0, which means they won't expire
Actually, this seems to remove cache, TTL will be set to false in normalizeTtl
method in Symfony\Component\Cache\Simple\AbstractCache
Not setting any ttl looks like the way to achieve wanted behavior for me. Do you agree ?
Current docs
I wasn't able to find information how to debug a variable while trying to help a newbe on slack:
Q: I am new with SilverStripe and I want to know if exists equivalent of print_r or var_dump inside SilverStripe template
A:
$Foo.Debug
shows the value of$Foo
. Indside a loop you can call$Me.Debug
to get the current variable in the loop
At which document do you think we should insert information about how to debug variables in templates? Would https://docs.silverstripe.org/en/4/developer_guides/debugging/template_debugging/ be good or should it go to the templates section, e.g. https://docs.silverstripe.org/en/4/developer_guides/templates/common_variables/ ?
Search docs ;)
v4.3.0
When extending ModelAdmin to add new pre-defined queries (e.g. a checkbox that will be used to filter adresses in Belgium - using later on the getlist function), the overwritten getSearchContext functions never called.
This is the code I used but you may simply use examples from your on-line developers doc (https://docs.silverstripe.org/en/4/developer_guides/customising_the_admin_interface/modeladmin/).
class Adress_Admin extends ModelAdmin {
private static $url_segment = 'Adress';
private static $menu_title = 'Adressen';
private static $managed_models = [Adress::class];
public function getSearchContext()
{
$context = parent::getSearchContext();
if($this->modelClass == 'bpf\Adress') {
$context->getFields()->push(new CheckboxField('q[InBelgiumA]', 'Only expensive stuff'));
}
return $context;
}
It's very easy to check - use e.g. error_log to trace the fact the function has been called.
Help us with step-by-step instructions.
ps: I know this will be depreciated in v5 but at least could you please provide an updated documentation on how to do it using GridfieldFilterHeader.
Thank you!!!
"Silverstripe" on its own should refer to the company (see #9 (comment)).
4.x
Currently the docs cover very basic can
permission implementations. One missing aspect of this is the importance to check permissions on your current model, then check against the parent
. This is most notable with Pages in the CMS module where the $context
param holds the ParentID
which is utilized to determine if a given page type can be created under another given parent page type.
Describe the how $context
is used in the CMS module as an example both for the ability to enhance permission logic with context, as well as the importance of that param when checking permissions if you are extending a class and providing custom permissions.
The current docs at https://github.com/silverstripe/silverstripe-framework/tree/master/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface are a hodge podge of legacy and new documentation. While some docs are marked as "deprecated", there's no clear learning path for new features.
The configuration documentation for the "Before / After Priorities" guide seems to be incorrect:
It states:
The value section above has two rules:
- It must be merged in before (lower priority than) all other value sections
- It must be merged in after (higher priority than) any value section with a fragment name of "rootroutes"
But the example does not have any "before" rule.
---
Name: adminroutes
# <- No before rule
After:
- '#rootroutes'
- '#coreroutes'
---
SilverStripe\Control\Director:
rules:
'admin': 'SilverStripe\Admin\AdminRootController'
---
Visiting the page https://docs.silverstripe.org/en/3/getting_started/installation/how_to/configure_nginx/ shows an empty section where the example Nginx config should be. It seems to have been removed in a commit that formatted the docs for Gatsby: silverstripe/silverstripe-framework@54e7223#diff-4bd44d58dc18b09f7a067b216a5f0916aa1a73ac93e51f3313ee0c9ae6465014L23
Along with several other code blocks that are examples. They should be probably all be added back in.
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.