[eGroupWare-svn] r55878 - in /trunk: admin/admin-cli.php egroupware/json.php

[email protected]
Newsgroups gmane.comp.web.egroupware.cvs
Message-ID <[email protected]>
Author: ralfbecker
Date: Wed Apr 27 12:34:57 2016
New Revision: 55878

URL: http://svn.stylite.de/viewvc/egroupware?rev=55878&view=rev
Log:
* 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

Modified:
    trunk/admin/admin-cli.php
    trunk/egroupware/json.php

Modified: trunk/admin/admin-cli.php
URL: http://svn.stylite.de/viewvc/egroupware/trunk/admin/admin-cli.php?rev=55878&r1=55877&r2=55878&view=diff
==============================================================================
--- trunk/admin/admin-cli.php (original)
+++ trunk/admin/admin-cli.php Wed Apr 27 12:34:57 2016
@@ -10,6 +10,8 @@
  * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
  * @version $Id$
  */
+
+use EGroupware\Api;
 
 chdir(dirname(__FILE__));	// to enable our relative pathes to work
 
@@ -113,7 +115,7 @@
  */
 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 @@
 	//_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";

Modified: trunk/egroupware/json.php
URL: http://svn.stylite.de/viewvc/egroupware/trunk/egroupware/json.php?rev=55878&r1=55877&r2=55878&view=diff
==============================================================================
--- trunk/egroupware/json.php (original)
+++ trunk/egroupware/json.php Wed Apr 27 12:34:57 2016
@@ -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);


------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.