From 9329b16ab13f3a4caf107df358c3c58bda2dcd8a Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 3 Nov 2010 18:35:31 +0100 Subject: [PATCH] [task/acm-refactor] Refactor the ACM classes to have a common interface. They are now refered to as cache drivers rather than ACM classes. The additional utility functions from the original cache class have been moved to the cache_service. The class loader is now instantiated without a cache instance and passed one as soon as it is constructed to allow autoloading the cache classes. PHPBB3-9983 --- phpBB/common.php | 12 +- phpBB/docs/coding-guidelines.html | 2 +- phpBB/download/file.php | 12 +- .../{acm/acm_apc.php => cache/driver/apc.php} | 8 +- phpBB/includes/cache/driver/base.php | 24 ++++ .../driver/eaccelerator.php} | 8 +- .../acm_file.php => cache/driver/file.php} | 6 +- phpBB/includes/cache/driver/interface.php | 104 ++++++++++++++++++ .../driver/memcache.php} | 12 +- .../driver/memory.php} | 4 +- .../acm_null.php => cache/driver/null.php} | 4 +- .../driver/xcache.php} | 14 +-- phpBB/includes/cache/factory.php | 52 +++++++++ .../includes/{cache.php => cache/service.php} | 57 ++++++---- phpBB/includes/class_loader.php | 21 ++-- phpBB/install/database_update.php | 11 +- phpBB/install/index.php | 7 +- phpBB/style.php | 15 ++- tests/bootstrap.php | 2 +- tests/cache/all_tests.php | 40 +++++++ tests/cache/cache_test.php | 39 +++++++ tests/class_loader/cache_mock.php | 49 ++++++++- tests/class_loader/class_loader_test.php | 14 ++- 23 files changed, 415 insertions(+), 102 deletions(-) rename phpBB/includes/{acm/acm_apc.php => cache/driver/apc.php} (88%) create mode 100644 phpBB/includes/cache/driver/base.php rename phpBB/includes/{acm/acm_eaccelerator.php => cache/driver/eaccelerator.php} (92%) rename phpBB/includes/{acm/acm_file.php => cache/driver/file.php} (98%) create mode 100644 phpBB/includes/cache/driver/interface.php rename phpBB/includes/{acm/acm_memcache.php => cache/driver/memcache.php} (92%) rename phpBB/includes/{acm/acm_memory.php => cache/driver/memory.php} (98%) rename phpBB/includes/{acm/acm_null.php => cache/driver/null.php} (95%) rename phpBB/includes/{acm/acm_xcache.php => cache/driver/xcache.php} (91%) create mode 100644 phpBB/includes/cache/factory.php rename phpBB/includes/{cache.php => cache/service.php} (85%) create mode 100644 tests/cache/all_tests.php create mode 100644 tests/cache/cache_test.php diff --git a/phpBB/common.php b/phpBB/common.php index 96b782a229..fc6009eb21 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -187,8 +187,6 @@ if (!empty($load_extensions) && function_exists('dl')) // Include files require($phpbb_root_path . 'includes/class_loader.' . $phpEx); -require($phpbb_root_path . 'includes/acm/acm_' . $acm_type . '.' . $phpEx); -require($phpbb_root_path . 'includes/cache.' . $phpEx); require($phpbb_root_path . 'includes/template.' . $phpEx); require($phpbb_root_path . 'includes/session.' . $phpEx); require($phpbb_root_path . 'includes/auth.' . $phpEx); @@ -203,13 +201,15 @@ require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); // Set PHP error handler to ours set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); -// Cache must be loaded before class loader -$cache = new cache(); - // Setup class loader first -$class_loader = new phpbb_class_loader($phpbb_root_path, '.' . $phpEx, $cache); +$class_loader = new phpbb_class_loader($phpbb_root_path, '.' . $phpEx); $class_loader->register(); +// set up caching +$acm = phpbb_cache_factory::create($acm_type)->get_acm(); +$class_loader->set_acm($acm); +$cache = new phpbb_cache_service($acm); + // Instantiate some basic classes $request = new phpbb_request(); $user = new user(); diff --git a/phpBB/docs/coding-guidelines.html b/phpBB/docs/coding-guidelines.html index 766242ab83..c0ebb7450e 100644 --- a/phpBB/docs/coding-guidelines.html +++ b/phpBB/docs/coding-guidelines.html @@ -203,7 +203,7 @@ class ...