Przeglądaj źródła

Optimization: make it less cumbersome to have the APC user cache enabled for PHP 5.5+. Prior to this enhancement, it used to require a compilation flag (for apcu) until PHP7... then it became mandatory to install a dedicated backward compatibility module named after apcu_bc. Now, having apcu installed and enabled is ENOUGH.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@4415 a333f486-631f-4898-b8df-5754b55c2be0
romainq 8 lat temu
rodzic
commit
20fc87e4da
2 zmienionych plików z 38 dodań i 0 usunięć
  1. 37 0
      core/apc-compat.php
  2. 1 0
      core/metamodel.class.php

+ 37 - 0
core/apc-compat.php

@@ -0,0 +1,37 @@
+<?php
+// Copyright (C) 2016 Combodo SARL
+//
+//   This file is part of iTop.
+//
+//   iTop is free software; you can redistribute it and/or modify	
+//   it under the terms of the GNU Affero General Public License as published by
+//   the Free Software Foundation, either version 3 of the License, or
+//   (at your option) any later version.
+//
+//   iTop is distributed in the hope that it will be useful,
+//   but WITHOUT ANY WARRANTY; without even the implied warranty of
+//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//   GNU Affero General Public License for more details.
+//
+//   You should have received a copy of the GNU Affero General Public License
+//   along with iTop. If not, see <http://www.gnu.org/licenses/>
+
+if (!function_exists('apc_store') && function_exists('apcu_store'))
+{
+	// Emulate the API of APC, over APCU
+	// Note: for PHP < 7, this compatibility used to be provided by APCU itself (if compiled with some options)
+	//       for PHP 7+, it can be provided by the mean of apcu_bc, which is not so simple to install
+	//       The current emulation aims at skipping this complexity
+	function apc_store($key, $var, $ttl = 0)
+	{
+		return apcu_store($key, $var, $ttl);
+	}
+	function apc_fetch($key)
+	{
+		return apcu_fetch($key);
+	}
+	function apc_delete($key)
+	{
+		return apcu_delete($key);
+	}
+}

+ 1 - 0
core/metamodel.class.php

@@ -22,6 +22,7 @@ require_once(APPROOT.'core/querymodifier.class.inc.php');
 require_once(APPROOT.'core/metamodelmodifier.inc.php');
 require_once(APPROOT.'core/computing.inc.php');
 require_once(APPROOT.'core/relationgraph.class.inc.php');
+require_once(APPROOT.'core/apc-compat.php');
 
 /**
  * Metamodel