mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 06:30:59 +01:00
* Admin: clear cache after admin-cli.php commands, so they become active automatically
and allow to send json requests with basic auth credentials without an active session, used here to clear cache via webservice call, as we can NOT clear shared memmory cache of webserver from cli
This commit is contained in:
parent
9f8f8891fb
commit
07a5224025
@ -11,6 +11,8 @@
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
use EGroupware\Api;
|
||||
|
||||
chdir(dirname(__FILE__)); // to enable our relative pathes to work
|
||||
|
||||
if (php_sapi_name() !== 'cli') // security precaution: forbit calling admin-cli as web-page
|
||||
@ -113,7 +115,7 @@ exit(0);
|
||||
*/
|
||||
function run_command(admin_cmd $cmd)
|
||||
{
|
||||
global $arguments;
|
||||
global $arguments,$user,$arg0s,$domain;
|
||||
|
||||
$skip_checks = false;
|
||||
while ($arguments && ($extra = array_shift($arguments)))
|
||||
@ -168,6 +170,24 @@ function run_command(admin_cmd $cmd)
|
||||
//_debug_array($cmd);
|
||||
try {
|
||||
print_r($cmd->run($time, true, $skip_checks, $dry_run));
|
||||
|
||||
// cli can NOT clear instance cache of APC(u), as cli uses different shared memory then webserver
|
||||
// --> we use a webservice call to clear cache (might fail if no domain in specified in webserver_url or on command line)
|
||||
if (!$dry_run)
|
||||
{
|
||||
$url = $GLOBALS['egw_info']['server']['webserver_url'].'/json.php?menuaction=admin.admin_hooks.ajax_clear_cache';
|
||||
if ($url[0] == '/') $url = 'http://'.(!empty($domain) && $domain != 'default' ? $domain : 'localhost').$url;
|
||||
$data = file_get_contents($url, false, Api\Framework::proxy_context($user,$arg0s[1]));
|
||||
error_log("file_get_contents('$url') returned ".array2string($data));
|
||||
if ($data && strpos($data, '"success"') !== false)
|
||||
{
|
||||
error_log('Instance cache cleared.');
|
||||
}
|
||||
else
|
||||
{
|
||||
error_log('You might need to clear the cache for changes to be visiable: Admin >> Clear cache!');
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (egw_exception_wrong_userinput $e) {
|
||||
echo "\n".$e->getMessage()."\n\n";
|
||||
|
10
json.php
10
json.php
@ -10,17 +10,23 @@
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
use EGroupware\Api;
|
||||
use EGroupware\Api\Json;
|
||||
|
||||
/**
|
||||
* callback if the session-check fails, redirects to login.php
|
||||
* callback if the session-check fails, redirects to login.php, if no valid basic auth credentials given
|
||||
*
|
||||
* @param array &$anon_account anon account_info with keys 'login', 'passwd' and optional 'passwd_type'
|
||||
* @return boolean|string true if we allow anon access and anon_account is set, a sessionid or false otherwise
|
||||
*/
|
||||
function login_redirect(&$anon_account)
|
||||
{
|
||||
unset($anon_account);
|
||||
// allow to make json calls via basic auth
|
||||
if (!empty($_SERVER['PHP_AUTH_USER']) && !empty($_SERVER['PHP_AUTH_PW']) &&
|
||||
($session_id = Api\Header\Authenticate::autocreate_session_callback($anon_account)))
|
||||
{
|
||||
return $session_id;
|
||||
}
|
||||
Json\Request::isJSONRequest(true); // because egw_json_request::parseRequest() is not (yet) called
|
||||
$response = Json\Response::get();
|
||||
$response->redirect($GLOBALS['egw_info']['server']['webserver_url'].'/login.php?cd=10', true);
|
||||
|
Loading…
Reference in New Issue
Block a user