Skip to content

Commit 93c6a34

Browse files
committed
🚀 Kirby v5 ready
Signed-off-by: Bruno Meilick <[email protected]>
1 parent aa0abe3 commit 93c6a34

File tree

4 files changed

+35
-10
lines changed

4 files changed

+35
-10
lines changed

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "Kirby Section to display recently modified content pages",
44
"license": "MIT",
55
"type": "kirby-plugin",
6-
"version": "4.3.0",
6+
"version": "5.0.0",
77
"authors": [
88
{
99
"name": "Bruno Meilick",
@@ -33,6 +33,9 @@
3333
"getkirby/composer-installer": true
3434
}
3535
},
36+
"conflict": {
37+
"getkirby/cms": "<5.0.0"
38+
},
3639
"scripts": {
3740
"fix": "php-cs-fixer fix",
3841
"test": [

index.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,10 @@
8888
return pages($keys ?? []);
8989
},
9090
'modifiedTimestamp' => function () {
91-
return filemtime(site()->storage()->contentFiles(site()->storage()->defaultVersion())[0]);
91+
$t = filemtime(site()->root().
92+
(kirby()->multilang()?'/site.'.kirby()->defaultLanguage()->code().'.txt':'/site.txt')
93+
);
94+
return $t ?: time();
9295
},
9396
'trackModifiedByUser' => function (bool $add = true): bool {
9497
if (!kirby()->user() || option('bnomei.recently-modified.hooks') !== true) {

vendor/composer/InstalledVersions.php

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ class InstalledVersions
3232
*/
3333
private static $installed;
3434

35+
/**
36+
* @var bool
37+
*/
38+
private static $installedIsLocalDir;
39+
3540
/**
3641
* @var bool|null
3742
*/
@@ -309,6 +314,12 @@ public static function reload($data)
309314
{
310315
self::$installed = $data;
311316
self::$installedByVendor = array();
317+
318+
// when using reload, we disable the duplicate protection to ensure that self::$installed data is
319+
// always returned, but we cannot know whether it comes from the installed.php in __DIR__ or not,
320+
// so we have to assume it does not, and that may result in duplicate data being returned when listing
321+
// all installed packages for example
322+
self::$installedIsLocalDir = false;
312323
}
313324

314325
/**
@@ -322,19 +333,27 @@ private static function getInstalled()
322333
}
323334

324335
$installed = array();
336+
$copiedLocalDir = false;
325337

326338
if (self::$canGetVendors) {
339+
$selfDir = strtr(__DIR__, '\\', '/');
327340
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
341+
$vendorDir = strtr($vendorDir, '\\', '/');
328342
if (isset(self::$installedByVendor[$vendorDir])) {
329343
$installed[] = self::$installedByVendor[$vendorDir];
330344
} elseif (is_file($vendorDir.'/composer/installed.php')) {
331345
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
332346
$required = require $vendorDir.'/composer/installed.php';
333-
$installed[] = self::$installedByVendor[$vendorDir] = $required;
334-
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
335-
self::$installed = $installed[count($installed) - 1];
347+
self::$installedByVendor[$vendorDir] = $required;
348+
$installed[] = $required;
349+
if (self::$installed === null && $vendorDir.'/composer' === $selfDir) {
350+
self::$installed = $required;
351+
self::$installedIsLocalDir = true;
336352
}
337353
}
354+
if (self::$installedIsLocalDir && $vendorDir.'/composer' === $selfDir) {
355+
$copiedLocalDir = true;
356+
}
338357
}
339358
}
340359

@@ -350,7 +369,7 @@ private static function getInstalled()
350369
}
351370
}
352371

353-
if (self::$installed !== array()) {
372+
if (self::$installed !== array() && !$copiedLocalDir) {
354373
$installed[] = self::$installed;
355374
}
356375

vendor/composer/installed.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php return array(
22
'root' => array(
33
'name' => 'bnomei/kirby3-recently-modified',
4-
'pretty_version' => '4.3.0',
5-
'version' => '4.3.0.0',
4+
'pretty_version' => '5.0.0',
5+
'version' => '5.0.0.0',
66
'reference' => null,
77
'type' => 'kirby-plugin',
88
'install_path' => __DIR__ . '/../../',
@@ -11,8 +11,8 @@
1111
),
1212
'versions' => array(
1313
'bnomei/kirby3-recently-modified' => array(
14-
'pretty_version' => '4.3.0',
15-
'version' => '4.3.0.0',
14+
'pretty_version' => '5.0.0',
15+
'version' => '5.0.0.0',
1616
'reference' => null,
1717
'type' => 'kirby-plugin',
1818
'install_path' => __DIR__ . '/../../',

0 commit comments

Comments
 (0)