PluginProbe
Seraphinite Accelerator / trunk
Seraphinite Accelerator vtrunk
2.29.24 2.29.23 2.29.22 2.29.21 2.29.20 2.29.19 2.29.18 2.29.17 2.29.16 2.29.15 2.29.14 2.29.13 2.29.12 2.29.11 2.29.10 2.29.9 2.20.18 2.20.19 2.20.2 2.20.20 2.20.21 2.20.22 2.20.23 2.20.24 2.20.25 All 418 releases
seraphinite-accelerator / cache.php

cache.php in Seraphinite Accelerator trunk, at cache.php

642 lines 18.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace seraph_accel;
4
5 if( !defined( 'ABSPATH' ) )
6 exit;
7
8 if( defined( 'SERAPH_ACCEL_NO_CACHE' ) )
9 return;
10
11 if( !defined( 'SERAPH_ACCEL_PLUGIN_DIR' ) ) define( 'SERAPH_ACCEL_PLUGIN_DIR', __DIR__ ); else if( SERAPH_ACCEL_PLUGIN_DIR != __DIR__ ) return;
12
13 require_once( __DIR__ . '/common.php' );
14 require_once( __DIR__ . '/cache_ex.php' );
15
16 global $seraph_accel_g_cacheSkipData;
17 global $seraph_accel_sites;
18
19 if( !$seraph_accel_sites )
20 return;
21
22 $hr = _Process( $seraph_accel_sites );
23
24 if( $hr == Gen::S_OK || Gen::HrFail( $hr ) )
25 {
26 if( isset( $args[ 'seraph_accel_gp' ] ) || !CacheDoCronAndEndRequest() )
27 {
28
29 flush();
30 exit();
31 }
32
33 return;
34 }
35
36 if( $hr == Gen::S_NOTIMPL )
37 return;
38
39 if( $hr == Gen::S_IO_PENDING )
40 {
41
42 ob_start( 'seraph_accel\\_CbContentFinish' );
43 ob_start( 'seraph_accel\\_CbContentProcess' );
44 }
45 else if( $seraph_accel_g_cacheSkipData )
46 {
47
48 ob_start( 'seraph_accel\\_CbContentFinishSkip' );
49 ob_start( 'seraph_accel\\_CbContentProcess' );
50 }
51
52 function _Process( $sites )
53 {
54 $requestMethod = strtoupper( ($_SERVER[ 'REQUEST_METHOD' ]??'GET') );
55 $args = $_GET;
56
57 global $seraph_accel_g_noFo;
58 global $seraph_accel_g_prepPrms;
59 global $seraph_accel_g_lazyInvTmp;
60 global $seraph_accel_g_cacheSkipData;
61 global $seraph_accel_g_siteId;
62 global $seraph_accel_g_cacheCtxSkip;
63 global $seraph_accel_g_simpCacheMode;
64
65 if( ( $requestMethod == 'GET' ) && isset( $_SERVER[ 'HTTP_X_SERAPH_ACCEL_TEST' ] ) )
66 {
67 if( $idTest = Gen::SanitizeId( substr( $_SERVER[ 'HTTP_X_SERAPH_ACCEL_TEST' ], 0, 64 ) ) )
68 {
69 @header( 'X-Seraph-Accel-test: ' . $idTest );
70 @header( 'ETag: "001122334455667788"' );
71 }
72
73 unset( $idTest );
74 }
75
76 $seraph_accel_g_prepPrms = CacheExtractPreparePageParams( $args );
77 if( $seraph_accel_g_prepPrms !== null )
78 {
79
80 BatCache_DontProcessCurRequest( true );
81
82 if( $seraph_accel_g_prepPrms === false )
83 {
84 http_response_code( 400 );
85 return( Gen::E_INVALIDARG );
86 }
87
88 @ignore_user_abort( true );
89 Gen::SetTimeLimit( 570 );
90
91 if( ($seraph_accel_g_prepPrms[ 'selfTest' ]??null) )
92 {
93 $seraph_accel_g_cacheSkipData = array( 'skipped', array( 'reason' => 'selfTest' ) );
94 return( Gen::S_FALSE );
95 }
96
97 if( !ProcessCtlData_Update( ($seraph_accel_g_prepPrms[ 'pc' ]??null), array( 'stage' => 'get' ), false, true ) )
98 {
99 http_response_code( 599 );
100 return( Gen::E_FAIL );
101 }
102
103 }
104
105 {
106 if( isset( $_SERVER[ 'HTTP_X_SERAPH_ACCEL_POSTPONE_USER_AGENT' ] ) )
107 {
108 $_SERVER[ 'HTTP_USER_AGENT' ] = $_SERVER[ 'HTTP_X_SERAPH_ACCEL_POSTPONE_USER_AGENT' ];
109 unset( $_SERVER[ 'HTTP_X_SERAPH_ACCEL_POSTPONE_USER_AGENT' ] );
110
111 }
112 }
113
114 $siteUriRoot = ''; GetContCacheEarlySkipData( $pathOrig, $path, $pathIsDir, $args );
115 if( $pathOrig !== null )
116 {
117 $host = GetRequestHost( $_SERVER );
118 $addrSite = $host;
119
120 $seraph_accel_g_siteId = GetCacheSiteIdAdjustPath( $sites, $addrSite, $siteSubId, $path );
121 if( $seraph_accel_g_siteId === null )
122 $seraph_accel_g_cacheSkipData = array( 'skipped', array( 'reason' => 'siteIdUnk' ) );
123 else
124 $siteUriRoot = substr( $addrSite, strlen( $host ) );
125
126 unset( $addrSite, $host );
127 }
128
129 $settGlob = Plugin::SettGet( Gen::CallFunc( 'seraph_accel_siteSettInlineDetach', array( 'm' ) ) );
130 if( $seraph_accel_g_siteId != 'm' )
131 {
132 if( Wp::IsMultisite() )
133 PluginOptions::SetBlogId( GetBlogIdFromSiteId( $seraph_accel_g_siteId ) );
134 $sett = Plugin::SettGet( Gen::CallFunc( 'seraph_accel_siteSettInlineDetach', array( $seraph_accel_g_siteId ) ) );
135 PluginOptions::UnsetBlogId();
136 }
137 else
138 $sett = $settGlob;
139
140 $settCache = Gen::GetArrField( $sett, array( 'cache' ), array() );
141
142 $timeoutCln = Gen::GetArrField( $settCache, array( 'timeoutCln' ), 0 ) * 60;
143 $timeout = ($settCache[ 'updByTimeout' ]??true) ? ( Gen::GetArrField( $settCache, array( 'timeout' ), 0 ) * 60 ) : 0;
144
145 InitTimeoutClnForWpNonce( $settCache );
146
147 if( ( $requestMethod == 'GET' ) && isset( $_REQUEST[ 'seraph_accel_gf' ] ) )
148 {
149 @header( 'X-Robots-Tag: noindex' );
150
151 $seraph_accel_g_simpCacheMode = 'fragments:' . Gen::SanitizeId( $_REQUEST[ 'seraph_accel_gf' ] );
152
153 $timeoutCln = Gen::GetArrField( $settCache, array( 'timeoutFrCln' ), 0 );
154 $timeout = Gen::GetArrField( $settCache, array( 'timeoutFr' ), 0 );
155
156 }
157
158 if( $seraph_accel_g_simpCacheMode === null && Gen::GetArrField( $settCache, array( 'ctxSkip' ), false ) )
159 $seraph_accel_g_cacheCtxSkip = true;
160
161 $idSubPart = ( $requestMethod == 'GET' ) ? Gen::SanitizeId( ($_REQUEST[ 'seraph_accel_gp' ]??null), null ) : null;
162 if( $idSubPart )
163 {
164 @header( 'X-Robots-Tag: noindex' );
165 Net::CurRequestRemoveArgs( $args, array( 'seraph_accel_gp' ) );
166 }
167
168 $requestMethodCache = 'GET';
169 {
170 $itemDataFound = null;
171 if( ( $requestMethod == 'GET' ) && isset( $_REQUEST[ 'seraph_accel_gbnr' ] ) )
172 {
173 $itemDataFound = array(
174 'type' => 'GET', 'mime' => 'text/plain',
175 'exclArgsAll' => false, 'exclArgs' => array(),
176 'skipArgsEnable' => true, 'skipArgsAll' => false, 'skipArgs' => array( '!seraph_accel_gbnr' ),
177 'timeoutCln' => 60 * 60 * 24, 'timeout' => 60, 'lazyInv' => true,
178 );
179 }
180 else
181 {
182 $requestURICheck = null;
183 foreach( Gen::GetArrField( $settCache, array( 'data', 'items' ), array() ) as $itemData )
184 {
185 if( !($itemData[ 'enable' ]??null) )
186 continue;
187
188 if( $requestMethod != ($itemData[ 'type' ]??'GET') )
189 continue;
190
191 $found = false;
192 foreach( ExprConditionsSet_Parse( ($itemData[ 'pattern' ]??'') ) as $e )
193 {
194 if( $requestURICheck === null )
195 {
196 $requestURICheck = $_SERVER[ 'REQUEST_URI' ];
197
198 if( $requestMethod == 'POST' )
199 {
200 AddCurPostArgs( $args );
201 if( $path && Gen::StrStartsWith( $path, Gen::GetArrField( $settCache, array( '_restUrlPrefix' ), 'RESTURLPREFIX_DUMMY' ) . '/' ) )
202 {
203
204 global $HTTP_RAW_POST_DATA;
205 if( !isset( $HTTP_RAW_POST_DATA ) )
206 $HTTP_RAW_POST_DATA = file_get_contents( 'php://input' );
207 if( strlen( $HTTP_RAW_POST_DATA ) )
208 $args[ '__body' ] = $HTTP_RAW_POST_DATA;
209 }
210
211 $requestURICheck = Net::UrlAddArgs( $requestURICheck, $args );
212 }
213 }
214
215 $val = false;
216 if( IsStrRegExp( $e[ 'expr' ] ) )
217 {
218 if( @preg_match( $e[ 'expr' ], $requestURICheck ) )
219 $val = true;
220 }
221 else if( strpos( $requestURICheck, $e[ 'expr' ] ) !== false )
222 $val = true;
223
224 if( !ExprConditionsSet_ItemOp( $e, $val ) )
225 {
226 $found = false;
227 break;
228 }
229
230 $found = true;
231 }
232
233 if( $found )
234 {
235 $itemDataFound = $itemData;
236 break;
237 }
238 }
239 }
240
241 if( $itemDataFound )
242 {
243 $seraph_accel_g_simpCacheMode = 'data:' . Fs::GetFileTypeFromMimeContentType( ($itemDataFound[ 'mime' ]??''), 'bin' );
244
245 foreach( array( 'exclArgsAll', 'exclArgs', 'skipArgsEnable', 'skipArgsAll', 'skipArgs' ) as $fld )
246 Gen::SetArrField( $settCache, array( $fld ), Gen::GetArrField( $itemDataFound, array( $fld ) ) );
247 $requestMethodCache = ($itemDataFound[ 'type' ]??'GET');
248 $timeoutCln = Gen::GetArrField( $itemDataFound, array( 'timeoutCln' ), 0 );
249 $timeout = Gen::GetArrField( $itemDataFound, array( 'timeout' ), 0 );
250
251 if( $pathOrig !== null && $seraph_accel_g_cacheSkipData )
252 $seraph_accel_g_cacheSkipData = null;
253 }
254
255 unset( $requestURICheck, $itemData, $itemDataFound, $found, $val );
256 }
257
258 if( $requestMethod != $requestMethodCache )
259 {
260 if( $requestMethod != 'GET' )
261 $seraph_accel_g_cacheSkipData = null;
262 return( Gen::S_FALSE );
263 }
264
265 if( $seraph_accel_g_cacheSkipData )
266 {
267
268 BatCache_DontProcessCurRequest();
269
270 _ProcessOutHdrTrace( $sett, true, true, $seraph_accel_g_cacheSkipData[ 0 ], ($seraph_accel_g_cacheSkipData[ 1 ]??null) );
271 if( $seraph_accel_g_prepPrms !== null )
272 ProcessCtlData_Update( ($seraph_accel_g_prepPrms[ 'pc' ]??null), array_merge( array( 'finish' => true, 'skip' => Gen::GetArrField( ($seraph_accel_g_cacheSkipData[ 1 ]??null), array( 'reason' ), '' ) ), ($sett[ 'debugInfo' ]??null) ? array( 'infos' => array( LocId::Pack( 'SrvArgs' ) => PackKvArrInfo( $_SERVER ) ) ) : array() ), false, false );
273 return( Gen::S_NOTIMPL );
274 }
275
276 if( GetContentProcessorForce( $sett ) !== null )
277 {
278
279 BatCache_DontProcessCurRequest();
280
281 $seraph_accel_g_cacheSkipData = array( 'skipped', array( 'reason' => 'debugContProcForce' ) );
282
283 return( Gen::S_FALSE );
284 }
285
286 {
287 $exclStatus = ContProcGetExclStatus( $seraph_accel_g_siteId, $settCache, $path, $pathOrig, $pathIsDir, $args, $varsOut, true, $seraph_accel_g_prepPrms === null );
288 if( $exclStatus )
289 {
290
291 BatCache_DontProcessCurRequest();
292
293 $seraph_accel_g_cacheSkipData = array( 'skipped', array( 'reason' => $exclStatus ) );
294
295 if( Gen::StrStartsWith( $exclStatus, 'excl' ) )
296 {
297
298 $debugData = ($seraph_accel_g_cacheSkipData[ 1 ]??null);
299 if( ($sett[ 'debugInfo' ]??null) )
300 $debugData[ 'args' ] = $args;
301
302 _ProcessOutHdrTrace( $sett, true, true, $seraph_accel_g_cacheSkipData[ 0 ], $debugData );
303 if( $seraph_accel_g_prepPrms !== null )
304 ProcessCtlData_Update( ($seraph_accel_g_prepPrms[ 'pc' ]??null), array_merge( array( 'finish' => true, 'skip' => $exclStatus ), ($sett[ 'debugInfo' ]??null) ? array( 'infos' => array( LocId::Pack( 'SrvArgs' ) => PackKvArrInfo( $_SERVER ) ) ) : array() ), false, false );
305 return( Gen::S_NOTIMPL );
306 }
307
308 return( Gen::S_FALSE );
309 }
310
311 extract( $varsOut );
312 Net::CurRequestRemoveArgs( $args, $aArgRemove );
313 unset( $varsOut, $exclStatus, $aArgRemove );
314 }
315
316 global $seraph_accel_g_dscFile;
317 global $seraph_accel_g_dscFilePending;
318 global $seraph_accel_g_dataPath;
319 global $seraph_accel_g_prepOrigContHashPrev;
320 global $seraph_accel_g_ctxCache;
321
322 $seraph_accel_g_ctxCache = new AnyObj();
323
324 $sessId = $userId ? ($sessInfo[ 'userSessId' ]??null) : ($sessInfo[ 'sessId' ]??null);
325 $aViewCookieMatched = array();
326 $viewId = GetCacheViewId( $seraph_accel_g_ctxCache, $settCache, $userAgent, $path, $pathOrig, $args, Gen::StrStartsWith( ( string )$seraph_accel_g_simpCacheMode, 'fragments' ), $aViewCookieMatched );
327 $seraph_accel_g_ctxCache -> viewId = $viewId;
328 $cacheRootPath = GetCacheDir();
329 $siteCacheRootPath = $cacheRootPath . '/s/' . $seraph_accel_g_siteId;
330 $seraph_accel_g_ctxCache -> viewPath = GetCacheViewsDir( $siteCacheRootPath, $siteSubId ) . '/' . $viewId;
331 $ctxsPath = $seraph_accel_g_ctxCache -> viewPath . '/c';
332
333 if( ($settCache[ 'normAgent' ]??null) )
334 add_action( 'template_redirect',
335 function()
336 {
337 if( !is_404() )
338 return;
339
340 if( isset( $_SERVER[ 'SERAPH_ACCEL_ORIG_USER_AGENT' ] ) )
341 $_SERVER[ 'HTTP_USER_AGENT' ] = $_SERVER[ 'SERAPH_ACCEL_ORIG_USER_AGENT' ];
342 }
343 , 0 );
344
345 add_filter( 'wp_redirect_status',
346 function( $status, $location )
347 {
348 global $seraph_accel_g_sRedirLocation;
349 $seraph_accel_g_sRedirLocation = $location;
350 return( $status );
351 }
352 , 99999, 2 );
353
354 {
355 $seraph_accel_g_ctxCache -> userId = $userId;
356 if( !$sessId || !$stateCookId || !Gen::GetArrField( $settCache, array( 'ctxSessSep' ), false ) )
357 {
358 $seraph_accel_g_ctxCache -> userSessId = null;
359 $sessId = '@';
360 }
361 else
362 $seraph_accel_g_ctxCache -> userSessId = $sessId;
363 $seraph_accel_g_ctxCache -> isUserSess = $seraph_accel_g_ctxCache -> userId || $seraph_accel_g_ctxCache -> userSessId;
364
365 $ctxPathId = $userId . '/s/' . $sessId;
366
367 if( !$seraph_accel_g_cacheCtxSkip && Gen::GetArrField( $settCache, array( 'ctx' ), false ) )
368 {
369 $_SERVER[ 'HTTP_X_SERAPH_ACCEL_SESSID' ] = $userId . '/' . $sessId;
370
371 if( $seraph_accel_g_ctxCache -> isUserSess )
372 {
373 $ctxTimeoutCln = Gen::GetArrField( $settCache, array( 'ctxTimeoutCln' ), 0 ) * 60;
374 if( $timeoutCln > $ctxTimeoutCln )
375 $timeoutCln = $ctxTimeoutCln;
376 }
377 }
378
379 if( $stateCookId )
380 $stateCookId = md5( $stateCookId );
381 else
382 $stateCookId = '@';
383
384 $ctxPathId .= '/s/' . $stateCookId;
385 }
386
387 if( !$seraph_accel_g_ctxCache -> isUserSess || $seraph_accel_g_cacheCtxSkip )
388 Net::CurRequestSetCookies( $aViewCookieMatched );
389
390 $objectId = '@';
391 $objectType = 'html';
392 if( $pathIsDir )
393 $objectId .= 'd';
394 if( is_string( $seraph_accel_g_simpCacheMode ) )
395 {
396 if( Gen::StrStartsWith( $seraph_accel_g_simpCacheMode, 'fragments' ) )
397 $objectId .= 'f';
398 else if( Gen::StrStartsWith( $seraph_accel_g_simpCacheMode, 'data:' ) )
399 {
400
401 $objectType = substr( $seraph_accel_g_simpCacheMode, 5 );
402 }
403 }
404
405 if( $requestMethod == 'POST' )
406 $objectId .= '-p';
407
408 if( !empty( $args ) )
409 {
410 $argsCumulative = '';
411 foreach( $args as $argKey => $argVal )
412 $argsCumulative .= $argKey . $argVal;
413
414 $objectId = $objectId . '.' . @md5( $argsCumulative );
415 unset( $argsCumulative );
416 }
417
418 $seraph_accel_g_dataPath = GetCacheDataDir( $siteCacheRootPath );
419
420 $seraph_accel_g_dscFile = $ctxsPath . '/' . $ctxPathId . '/o';
421 if( $path )
422 $seraph_accel_g_dscFile .= '/' . $path;
423 $seraph_accel_g_dscFile .= '/' . $objectId . '.' . $objectType . '.dat';
424
425 if( $seraph_accel_g_prepPrms && !ProcessCtlData_Update( ($seraph_accel_g_prepPrms[ 'pc' ]??null), array( 'dscFile' => $seraph_accel_g_dscFile ) ) )
426 {
427 http_response_code( 599 );
428 return( Gen::E_FAIL );
429 }
430
431 $seraph_accel_g_dscFilePending = $seraph_accel_g_dscFile . '.p';
432
433 if( $seraph_accel_g_prepPrms !== null )
434 {
435 $seraph_accel_g_dscFilePending .= 'p';
436 $seraph_accel_g_noFo = true;
437 }
438
439 $procTmLim = Gen::GetArrField( $settCache, array( 'procTmLim' ), 570 );
440
441 $sessExpiration = ($sessInfo[ 'expiration' ]??null);
442 if( !$sessExpiration )
443 $sessExpiration = $tmCur;
444
445 $httpCacheControl = strtolower( ($_SERVER[ 'HTTP_CACHE_CONTROL' ]??'') );
446
447 if( $timeoutCln && $timeout > $timeoutCln )
448 $timeout = $timeoutCln;
449
450 $reason = null;
451 $dsc = null;
452 $isCip = null;
453
454 $dscFileTm = Gen::FileMTime( $seraph_accel_g_dscFile );
455 $dscFileTmAge = $tmCur - $dscFileTm;
456
457 $bSkipCacheContentStart = false;
458 if( stripos( $userAgent, 'Seraph-Accel-Agent-WarmUp/' ) !== false )
459 $bSkipCacheContentStart = true;
460
461 if( !$bSkipCacheContentStart && ( !$dscFileTm || ( $timeoutCln > 0 && $dscFileTmAge > $timeoutCln && ( $dscFileTm >= 60 ) ) || ( $timeout > 0 ? ( $dscFileTmAge > $timeout ) : ( $dscFileTm < 60 ) ) || ( $tmCur > $sessExpiration ) || ( $seraph_accel_g_ctxCache -> isUserSess && $httpCacheControl == 'no-cache' && Gen::GetArrField( $settCache, array( 'ctxCliRefresh' ), false ) ) ) )
462 {
463 $lock = new Lock( 'dl', $cacheRootPath );
464 if( !$lock -> Acquire() )
465 return( Gen::E_FAIL );
466
467 $dscFileTm = Gen::FileMTime( $seraph_accel_g_dscFile );
468
469 if( $dscFileTm === false )
470 {
471 $ccs = _CacheContentStart( $tmCur, $procTmLim );
472 $lock -> Release();
473
474 if( $ccs )
475 {
476
477 return( Gen::S_IO_PENDING );
478 }
479
480 if( $seraph_accel_g_prepPrms !== null )
481 {
482 ProcessCtlData_Update( ($seraph_accel_g_prepPrms[ 'pc' ]??null), array_merge( array( 'finish' => true, 'skip' => 'alreadyProcessing' ), ($sett[ 'debugInfo' ]??null) ? array( 'infos' => array( LocId::Pack( 'SrvArgs' ) => PackKvArrInfo( $_SERVER ) ) ) : array() ), false, false );
483 return( Gen::S_OK );
484 }
485
486 if( $seraph_accel_g_simpCacheMode === null )
487 {
488 $seraph_accel_g_cacheSkipData = array( 'revalidating', array( 'reason' => 'initial', 'dscFile' => substr( $seraph_accel_g_dscFile, strlen( $cacheRootPath ) ) ) );
489 return( Gen::S_FALSE );
490 }
491
492 return( Gen::S_IO_PENDING );
493 }
494 else
495 {
496
497 $dsc = CacheReadDsc( $seraph_accel_g_dscFile );
498
499 $dscFileTmAge = $tmCur - $dscFileTm;
500
501 if( $dscFileTm === 0 )
502 {
503 $reason = 'forced';
504
505 }
506 else if( $timeoutCln > 0 && $dscFileTmAge > $timeoutCln && ( $dscFileTm >= 60 ) )
507 {
508 $reason = 'timeoutClnExpired';
509
510 }
511 else if( $timeout > 0 ? ( $dscFileTmAge > $timeout ) : ( $dscFileTm < 60 ) )
512 {
513 $reason = ( $dscFileTm === 5 ) ? 'initial' : ( ( $dscFileTm === 10 ) ? 'forced' : 'timeoutExpired' );
514
515 }
516 else if( $tmCur > $sessExpiration )
517 $reason = 'userSessionExpired';
518 else if( $seraph_accel_g_ctxCache -> isUserSess && $httpCacheControl == 'no-cache' && Gen::GetArrField( $settCache, array( 'ctxCliRefresh' ), false ) )
519 $reason = 'forcedFromClient';
520
521 if( $reason )
522 {
523 $ccs = _CacheContentStart( $tmCur, $procTmLim );
524 if( $ccs )
525 {
526 if( $dscFileTm === 0 && !@touch( $seraph_accel_g_dscFile, 10 ) )
527 {
528 $lock -> Release();
529 return( Gen::E_FAIL );
530 }
531
532 $lock -> Release();
533
534 {
535
536 return( Gen::S_IO_PENDING );
537 }
538 }
539 else
540 {
541 $lock -> Release();
542
543 $isCip = true;
544
545 {
546 if( !( $dsc && isset( $dsc[ 't' ] ) ) && $seraph_accel_g_prepPrms === null )
547 {
548 if( $seraph_accel_g_simpCacheMode === null )
549 {
550 $seraph_accel_g_cacheSkipData = array( 'revalidating', array( 'reason' => $reason, 'dscFile' => substr( $seraph_accel_g_dscFile, strlen( $cacheRootPath ) ) ) );
551 return( Gen::S_FALSE );
552 }
553
554 return( Gen::S_IO_PENDING );
555 }
556 }
557 }
558 }
559 else
560 $lock -> Release();
561 }
562
563 unset( $lock );
564 }
565 else
566 $dsc = CacheReadDsc( $seraph_accel_g_dscFile );
567
568 if( $seraph_accel_g_prepPrms === null )
569 {
570
571 $reasonOutputErr = null;
572 if( !$dsc )
573 {
574 if( $bSkipCacheContentStart )
575 return( Gen::S_FALSE );
576 $reasonOutputErr = 'brokenDsc';
577 }
578 else
579 {
580
581 $hr = _ProcessOutCachedData( $seraph_accel_g_simpCacheMode === null, null, $settGlob, $sett, $settCache, $dsc, $dscFileTm, $tmCur, $isCip ? 'revalidating' : ( $isCip === false ? 'revalidating-begin' : 'cache' ), $reason, true );
582 if( Gen::HrFail( $hr ) )
583 return( $hr );
584
585 if( $hr == Gen::S_FALSE )
586 $reasonOutputErr = 'brokenData';
587 }
588
589 if( $reasonOutputErr )
590 {
591 $lock = new Lock( 'dl', $cacheRootPath );
592 if( !$lock -> Acquire() )
593 return( Gen::E_FAIL );
594
595 @touch( $seraph_accel_g_dscFile, 0 );
596
597 if( $isCip === false || _CacheContentStart( $tmCur, $procTmLim ) )
598 {
599 $lock -> Release();
600
601 return( Gen::S_IO_PENDING );
602 }
603
604 $lock -> Release();
605
606 if( $seraph_accel_g_simpCacheMode === null )
607 {
608 $seraph_accel_g_cacheSkipData = array( 'revalidating', array( 'reason' => $reasonOutputErr, 'dscFile' => substr( $seraph_accel_g_dscFile, strlen( $cacheRootPath ) ) ) );
609 return( Gen::S_FALSE );
610 }
611
612 return( Gen::S_IO_PENDING );
613 }
614 }
615 else
616 $hr = Gen::S_OK;
617
618 if( $isCip === false )
619 {
620 if( $seraph_accel_g_prepPrms === null )
621 {
622 if( $bgEnabled = Gen::CloseCurRequestSessionForContinueBgWork() )
623 CacheFem();
624
625 $seraph_accel_g_noFo = true;
626 return( Gen::S_IO_PENDING );
627 }
628
629 $seraph_accel_g_noFo = true;
630 return( Gen::S_IO_PENDING );
631 }
632
633 if( $seraph_accel_g_prepPrms !== null )
634 {
635 ProcessCtlData_Update( ($seraph_accel_g_prepPrms[ 'pc' ]??null), array_merge( array( 'finish' => true, 'skip' => $isCip ? 'alreadyProcessing' : 'alreadyProcessed' ), ($sett[ 'debugInfo' ]??null) ? array( 'infos' => array( LocId::Pack( 'SrvArgs' ) => PackKvArrInfo( $_SERVER ) ) ) : array() ), false, false );
636 return( $hr );
637 }
638
639 return( $hr );
640 }
641
642