for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Creates initial version records for File objects that do not have any
* versioning information. This should be run when the module is first installed
* in order to bootstrap the version history.
*
* @package silverstripe-versionedfiles
*/
class FileVersionCreationTask extends BuildTask
{
public function getTitle()
return _t(
'FileVersionCreationTask.Title',
'File Version Creation Task'
);
}
public function getDescription()
'FileVersionCreationTask.Desc',
'Creates version records for files that do not have one.'
* @param HTTPRequest $request
public function run($request)
$versionless = File::get()->leftJoin(
'FileVersion',
'"FileVersion"."FileID" = "File"."ID"'
)->where('"File"."ClassName" <> \'Folder\' AND "FileVersion"."FileID" IS NULL');
$createdVersions = 0;
if ($versionless) {
foreach ($versionless as $file) {
if ($file->createVersion()) {
++$createdVersions;
if ($createdVersions) {
echo _t(
'FileVersionCreationTask.Created',
"Created {count} file version records.",
array('count' => $createdVersions)
array<string,integer,{"count":"integer"}>
string
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example:
function acceptsInteger($int) { } $x = '123'; // string "123" // Instead of acceptsInteger($x); // we recommend to use acceptsInteger((integer) $x);
} else {
'FileVersionCreationTask.NoCreated',
'No file version records created.'
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: