@@ -67,11 +67,11 @@ public function forceNewBoostId(bool $overwrite = false, ?string $id = null)
6767 public function contentBoostedKey (string $ languageCode = null ): string
6868 {
6969 $ key = strval (crc32 ($ this ->id ()));
70- if (!$ languageCode ) {
70+ if (! $ languageCode ) {
7171 $ languageCode = kirby ()->languages ()->count () ? kirby ()->language ()->code () : null ;
72- if ( $ languageCode ) {
73- $ key = $ key . ' - ' . $ languageCode;
74- }
72+ }
73+ if ( $ languageCode) {
74+ $ key = $ key . ' - ' . $ languageCode ;
7575 }
7676
7777 return $ key ;
@@ -84,14 +84,20 @@ public function isContentCacheExpiredByModified(string $languageCode = null): bo
8484 return true ;
8585 }
8686
87- $ modified = $ this ->modified ();
8887 $ modifiedCache = $ cache ->get (
8988 $ this ->contentBoostedKey ($ languageCode ).'-modified ' ,
9089 null
9190 );
9291 if (!$ modifiedCache ) {
9392 return true ;
9493 }
94+
95+ $ modified = $ this ->modified ();
96+ // in rare case the file does not exist or is not readable
97+ if ($ modified === false ) {
98+ return true ;
99+ }
100+ // otherwise compare
95101 if ($ modifiedCache && intval ($ modifiedCache ) < intval ($ modified )) {
96102 return true ;
97103 }
@@ -116,7 +122,7 @@ public function readContentCache(string $languageCode = null): ?array
116122 public function readContent (string $ languageCode = null ): array
117123 {
118124 // read from boostedCache if exists
119- $ data = option ('debug ' ) ? null : $ this ->readContentCache ($ languageCode );
125+ $ data = option ('bnomei.boost.read ' ) === false || option ( ' debug ' ) ? null : $ this ->readContentCache ($ languageCode );
120126
121127 // read from file and update boostedCache
122128 if (! $ data ) {
@@ -132,13 +138,20 @@ public function readContent(string $languageCode = null): array
132138 public function writeContentCache (?array $ data = null , string $ languageCode = null ): bool
133139 {
134140 $ cache = BoostCache::singleton ();
135- if (! $ cache ) {
141+ if (! $ cache || option ( ' bnomei.boost.write ' ) === false ) {
136142 return true ;
137143 }
138144
145+ $ modified = $ this ->modified ();
146+
147+ // in rare case file does not exists or is not readable
148+ if ($ modified === false ) {
149+ return false ; // try again another time
150+ }
151+
139152 $ cache ->set (
140153 $ this ->contentBoostedKey ($ languageCode ) . '-modified ' ,
141- $ this -> modified () ,
154+ $ modified ,
142155 option ('bnomei.boost.expire ' )
143156 );
144157
0 commit comments