Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/YOURLS/YOURLS.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOzh <ozh@ozh.org>2022-03-22 00:03:57 +0300
committerOzh <ozh@ozh.org>2022-03-22 00:03:57 +0300
commit4849e88d43cc7a23ed477c91477c1dd2ea0fcd30 (patch)
tree510295ff6b7d7e2bf1bc0124955bd03df22016fc
parent3828863675ce8257704e402ac4d9f7c8ee396168 (diff)
Add some plugin features :
- foolproof (?) activation sandbox that actually works - uninstall method
-rw-r--r--includes/functions-plugins.php14
1 files changed, 5 insertions, 9 deletions
diff --git a/includes/functions-plugins.php b/includes/functions-plugins.php
index 5b1f51bc..abbfdf31 100644
--- a/includes/functions-plugins.php
+++ b/includes/functions-plugins.php
@@ -636,17 +636,13 @@ function yourls_activate_plugin( $plugin ) {
return yourls__( 'Plugin already activated' );
}
- // attempt activation. TODO: uber cool fail proof sandbox like in WP.
- ob_start();
- include_once( $plugindir.'/'.$plugin );
- if ( ob_get_length() > 0 ) {
- // there was some output: error
- // @codeCoverageIgnoreStart
- $output = ob_get_clean();
+ // attempt activation.
+ try {
+ include_once( $plugindir.'/'.$plugin );
+ } catch ( \Throwable $e ) {
+ $output = $e->getMessage();
return yourls_s( 'Plugin generated unexpected output. Error was: <br/><pre>%s</pre>', $output );
- // @codeCoverageIgnoreEnd
}
- ob_end_clean();
// so far, so good: update active plugin list
$ydb->add_plugin( $plugin );