[eGroupWare-svn] r55877 - in /branches/14.2: admin/ admin/admin-cli.php admin/inc/class.admin_hooks.inc.php egroupware/json.php

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

URL: http://svn.stylite.de/viewvc/egroupware?rev=55877&view=rev
Log:
* Admin: clear cache after admin-cli.php commands, so they become active automatically, also backported feedback for "Clear cache and register hooks" from trunk
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:
    branches/14.2/admin/   (props changed)
    branches/14.2/admin/admin-cli.php
    branches/14.2/admin/inc/class.admin_hooks.inc.php
    branches/14.2/egroupware/json.php

Propchange: branches/14.2/admin/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Apr 27 12:13:34 2016
@@ -1,2 +1,2 @@
 /branches/14.1/admin:51499
-/trunk/admin:51376,51460,51639,51699,51770,51810,51812,51817,51836,51855,51878,52247,52357,52451,52481,52520,52550-52551,52572,52574,52780,52958,53021-53022,53024,53026,53042,53044,53087,53116,53146-53147,53198,53287,53667,53705,53707,53712,53726,53732,53753,53772,53787,53828,53960,53991,54030,54032,54050,54156,54158,54444-54445,54452,54472,54522,54529,54533,54545
+/trunk/admin:51376,51460,51639,51699,51770,51810,51812,51817,51836,51855,51878,52247,52357,52451,52481,52520,52550-52551,52572,52574,52780,52958,53021-53022,53024,53026,53042,53044,53087,53116,53146-53147,53198,53287,53667,53705,53707,53712,53726,53732,53753,53772,53787,53828,53960,53991,54030,54032,54050,54156,54158,54444-54445,54452,54472,54522,54529,54533,54545,55095

Modified: branches/14.2/admin/admin-cli.php
URL: http://svn.stylite.de/viewvc/egroupware/branches/14.2/admin/admin-cli.php?rev=55877&r1=55876&r2=55877&view=diff
==============================================================================
--- branches/14.2/admin/admin-cli.php (original)
+++ branches/14.2/admin/admin-cli.php Wed Apr 27 12:13:34 2016
@@ -112,7 +112,7 @@
  */
 function run_command(admin_cmd $cmd)
 {
-	global $arguments;
+	global $arguments,$user,$arg0s,$domain;
 
 	$skip_checks = false;
 	while ($arguments && ($extra = array_shift($arguments)))
@@ -167,6 +167,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, egw_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";
@@ -427,7 +445,7 @@
 	catch (Exception $e) {	// new account
 		$data['account_lid'] = $account;
 		$account = false;
-	};
+	}
 	run_command(new admin_cmd_edit_user($account,$data,null,$run_addaccount_hook));
 }
 

Modified: branches/14.2/admin/inc/class.admin_hooks.inc.php
URL: http://svn.stylite.de/viewvc/egroupware/branches/14.2/admin/inc/class.admin_hooks.inc.php?rev=55877&r1=55876&r2=55877&view=diff
==============================================================================
--- branches/14.2/admin/inc/class.admin_hooks.inc.php (original)
+++ branches/14.2/admin/inc/class.admin_hooks.inc.php Wed Apr 27 12:13:34 2016
@@ -112,7 +112,12 @@
 
 			if (! $GLOBALS['egw']->acl->check('applications_acc',16,'admin'))
 			{
-				$file['Clear cache and register hooks'] = egw::link('/index.php','menuaction=admin.admin_hooks.register_all_hooks');
+				$file['Clear cache and register hooks'] = array(
+					'id' => 'admin/clear_cache',
+					'no_lang' => true,
+					'link' => "javascript:egw.message('".lang('Clear cache and register hooks') . "<br />" .lang('Please wait...')."','info'); " .
+						"egw.json('admin.admin_hooks.ajax_clear_cache').sendRequest(true);"
+				 );
 			}
 
 			if (! $GLOBALS['egw']->acl->check('asyncservice_acc',1,'admin'))
@@ -152,9 +157,9 @@
 	}
 
 	/**
-	 * Register all hooks
-	 */
-	function register_all_hooks()
+	 * Clears instance cache and register hooks
+	 */
+	function ajax_clear_cache()
 	{
 		if ($GLOBALS['egw']->acl->check('applications_acc',16,'admin'))
 		{
@@ -173,7 +178,7 @@
 		// allow apps to hook into "Admin >> Clear cache and register hooks"
 		$GLOBALS['egw']->hooks->process('clear_cache', array(), true);
 
-		$GLOBALS['egw']->redirect_link('/admin/index.php');
+		egw_json_response::get()->apply('egw.message', array(lang('Done'), 'success'));
 	}
 
 	/**

Modified: branches/14.2/egroupware/json.php
URL: http://svn.stylite.de/viewvc/egroupware/branches/14.2/egroupware/json.php?rev=55877&r1=55876&r2=55877&view=diff
==============================================================================
--- branches/14.2/egroupware/json.php (original)
+++ branches/14.2/egroupware/json.php Wed Apr 27 12:13:34 2016
@@ -11,13 +11,19 @@
  */
 
 /**
- * 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)
 {
+	// allow to make json calls via basic auth
+	if (!empty($_SERVER['PHP_AUTH_USER']) && !empty($_SERVER['PHP_AUTH_PW']) &&
+		($session_id = egw_digest_auth::autocreate_session_callback($anon_account)))
+	{
+		return $session_id;
+	}
 	unset($anon_account);
 	egw_json_request::isJSONRequest(true);	// because egw_json_request::parseRequest() is not (yet) called
 	$response = egw_json_response::get();


------------------------------------------------------------------------------
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.