Skip to content

Commit ea85892

Browse files
committed
Add option to forcefully invalidate opcache entries
1 parent bd59888 commit ea85892

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

cache.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,11 @@ function sort_list(&$list) {
116116

117117
if( isset( $_GET['action'] ) && $_GET['action'] == 'op_delete' ) {
118118
$selector = get_selector();
119+
119120
foreach( $opcache['scripts'] as $key => $value ) {
120121
if( !preg_match( $selector, $key) ) continue;
121122

122-
opcache_invalidate( $key );
123+
opcache_invalidate( $key, empty($_GET['force'])?false:true );
123124
}
124125
redirect('?action=op_select&selector=' . $_GET['selector'] );
125126
}
@@ -198,6 +199,10 @@ function sort_list(&$list) {
198199
</label>
199200
<button type="submit" name="action" value="op_select">Select</button>
200201
<button type="submit" name="action" value="op_delete">Delete</button>
202+
<label>
203+
<input name="force" type="checkbox" />
204+
Force deletion
205+
</label>
201206
</form>
202207
</div>
203208
<?php if( isset( $_GET['action'] ) && $_GET['action'] == 'op_select' ): ?>
@@ -222,7 +227,10 @@ function sort_list(&$list) {
222227
<td><?=$item['full_path']?></td>
223228
<td><?=$item['hits']?></td>
224229
<td><?=human_size($item['memory_consumption'])?></td>
225-
<td><a href="?action=op_delete&selector=<?=urlencode('^'.$item['full_path'].'$')?>">Delete</a></td>
230+
<td>
231+
<a href="?action=op_delete&selector=<?=urlencode('^'.preg_quote($item['full_path']).'$')?>">Delete</a>
232+
<a href="?action=op_delete&force=1&selector=<?=urlencode('^'.preg_quote($item['full_path']).'$')?>">Force Delete</a>
233+
</td>
226234
</tr>
227235
<?php endforeach; ?>
228236
</tbody>

0 commit comments

Comments
 (0)