Minahito
minah****@users*****
2007年 4月 11日 (水) 12:41:34 JST
Index: xoops2jp/html/kernel/module.php diff -u xoops2jp/html/kernel/module.php:1.2.8.14.2.4.2.1 xoops2jp/html/kernel/module.php:1.2.8.14.2.4.2.2 --- xoops2jp/html/kernel/module.php:1.2.8.14.2.4.2.1 Wed Mar 28 14:45:56 2007 +++ xoops2jp/html/kernel/module.php Wed Apr 11 12:41:34 2007 @@ -1,5 +1,5 @@ <?php -// $Id: module.php,v 1.2.8.14.2.4.2.1 2007/03/28 05:45:56 minahito Exp $ +// $Id: module.php,v 1.2.8.14.2.4.2.2 2007/04/11 03:41:34 minahito Exp $ // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // // Copyright (c) 2000 XOOPS.org // @@ -373,13 +373,11 @@ */ function &get($id) { - static $_cachedModule_dirname; - static $_cachedModule_mid; $ret = false; $id = intval($id); if ($id > 0) { - if (!empty($_cachedModule_mid[$id])) { - return $_cachedModule_mid[$id]; + if (!empty($this->_cachedModule_mid[$id])) { + return $this->_cachedModule_mid[$id]; } else { $sql = 'SELECT * FROM '.$this->db->prefix('modules').' WHERE mid = '.$id; if ($result = $this->db->query($sql)) { @@ -388,8 +386,8 @@ $module =& new XoopsModule(); $myrow = $this->db->fetchArray($result); $module->assignVars($myrow); - $_cachedModule_mid[$id] =& $module; - $_cachedModule_dirname[$module->getVar('dirname')] =& $module; + $this->_cachedModule_mid[$id] =& $module; + $this->_cachedModule_dirname[$module->getVar('dirname')] =& $module; $ret =& $module; } } @@ -407,13 +405,11 @@ */ function &getByDirname($dirname) { - static $_cachedModule_mid; - static $_cachedModule_dirname; $ret = false; $dirname = trim($dirname); - if (!empty($_cachedModule_dirname[$dirname])) { - $ret = $_cachedModule_dirname[$dirname]; + if (!empty($this->_cachedModule_dirname[$dirname])) { + $ret = $this->_cachedModule_dirname[$dirname]; } else { $sql = "SELECT * FROM ".$this->db->prefix('modules')." WHERE dirname = ".$this->db->quoteString($dirname); if ($result = $this->db->query($sql)) { @@ -422,8 +418,8 @@ $module =& new XoopsModule(); $myrow = $this->db->fetchArray($result); $module->assignVars($myrow); - $_cachedModule_dirname[$dirname] =& $module; - $_cachedModule_mid[$module->getVar('mid')] =& $module; + $this->_cachedModule_dirname[$dirname] =& $module; + $this->_cachedModule_mid[$module->getVar('mid')] =& $module; $ret =& $module; } } @@ -434,6 +430,9 @@ /** * Write a module to the database * + * @remark This method unsets cache of the module, and re-contruct the cache. + * But this mechanism may break the reference to the previous cache.... + * Maybe that's no problem. But, we should notice it. * @param object &$module reference to a {@link XoopsModule} * @return bool **/ @@ -472,6 +471,10 @@ if (!empty($this->_cachedModule_mid[$mid])) { unset ($this->_cachedModule_mid[$mid]); } + + $this->_cachedModule_dirname[$dirname] =& $module; + $this->_cachedModule_mid[$mid] =& $module; + return true; }