OSDN Git Service

MERGE: リビジョン1860。Blogオブジェクトの作成にManagerクラスによるキャッシュ機構を利用
authorsakamocchi <o-takashi@sakamocchi.jp>
Sat, 19 May 2012 03:53:30 +0000 (12:53 +0900)
committersakamocchi <o-takashi@sakamocchi.jp>
Sat, 19 May 2012 03:53:56 +0000 (12:53 +0900)
Manager::getObject()はキャッシュ機構を持つため、Blogクラスのコンストラクタを置き換えることでSQL文による不要な問い合わせを削減することができ、サーバー側の応答速度の改善につながる。

Revision 1860:
CHANGE: use cache machanism of Manager class to generate Blog object
Manager::getBlog() has cache mechanism. This commit replace
constructor of Blog class to Manager::getBlog() to reduce the number of
SQL query.
http://nucleuscms.svn.sourceforge.net/viewvc/nucleuscms?view=revision&revision=1860

nucleus/convert/bloggercaif.php
nucleus/convert/greymatter.php
nucleus/convert/livejournal.php
nucleus/plugins/NP_Ping.php
nucleus/xmlrpc/api_blogger.inc.php
nucleus/xmlrpc/api_metaweblog.inc.php
nucleus/xmlrpc/api_mt.inc.php
nucleus/xmlrpc/api_nucleus.inc.php
nucleus/xmlrpc/server.php

index 39e3311..72c70bf 100644 (file)
@@ -283,7 +283,7 @@ while ($a_name = array_pop($authors)) {
 
 
 function bc_doConversion() {
-       global $HTTP_POST_VARS;
+       global $HTTP_POST_VARS, $manager;
 
        // 1. get all data
        $authorcount = intval($HTTP_POST_VARS['authorcount']);
@@ -347,7 +347,7 @@ function bc_doConversion() {
        }
 
        // add authors to blog team
-       $b = new Blog($nucleus_blogid);
+       $b =& $manager->getBlog($nucleus_blogid);
        global $catid;
        $catid = $b->getDefaultCategory();
 
index 88eb146..2221583 100644 (file)
@@ -266,7 +266,7 @@ fclose($filehandle);
 }
 
 function gmc_doConversion() {
-       global $HTTP_POST_VARS;
+       global $HTTP_POST_VARS, $manager;
 
        // 1. get all data
 
@@ -337,7 +337,7 @@ function gmc_doConversion() {
        }
 
        // add authors to blog team
-       $blog = new Blog($nucleus_blogid);
+       $blog =& $manager->getBlog($nucleus_blogid);
        global $catid;
        $catid = $blog->getDefaultCategory();
        for ($i=0;$i<$authorcount;$i++)
index e2972ab..a20f493 100644 (file)
@@ -226,7 +226,7 @@ function bc_assignMembers() {
 
 
 function bc_doConversion() {
-       global $HTTP_POST_VARS;
+       global $HTTP_POST_VARS, $manager;
 
        // 1. get all data
        $authorcount = intval($HTTP_POST_VARS['authorcount']);
@@ -290,7 +290,7 @@ function bc_doConversion() {
        }
 
        // add authors to blog team
-       $b = new Blog($nucleus_blogid);
+       $b =& $manager->getBlog($nucleus_blogid);
        global $catid;
        $catid = $b->getDefaultCategory();
 
index 4bea85f..d097cc3 100644 (file)
@@ -231,7 +231,9 @@ class NP_Ping extends NucleusPlugin
        
        public function pingPingomatic()
        {
-               $b = new Blog($this->myBlogId);
+               global $manager;
+               
+               $b =& $manager->getBlog($this->myBlogId);
                $message = new xmlrpcmsg(
                        'weblogUpdates.ping',
                        array(
@@ -248,7 +250,9 @@ class NP_Ping extends NucleusPlugin
        
        public function pingWeblogs()
        {
-               $b = new Blog($this->myBlogId);
+               global $manager;
+               
+               $b =& $manager->getBlog($this->myBlogId);
                $message = new xmlrpcmsg(
                        'weblogupdates.ping',
                        array(
@@ -265,7 +269,9 @@ class NP_Ping extends NucleusPlugin
        
        public function pingTechnorati()
        {
-               $b = new Blog($this->myBlogId);
+               global $manager;
+               
+               $b =& $manager->getBlog($this->myBlogId);
                $message = new xmlrpcmsg(
                        'weblogUpdates.ping',
                        array(
@@ -282,7 +288,9 @@ class NP_Ping extends NucleusPlugin
        
        public function pingBlogRollingDotCom()
        {
-               $b = new Blog($this->myBlogId);
+               global $manager;
+               
+               $b =& $manager->getBlog($this->myBlogId);
                $message = new xmlrpcmsg(
                        'weblogUpdates.ping',
                        array(
@@ -299,7 +307,9 @@ class NP_Ping extends NucleusPlugin
        
        public function pingBloGs()
        {
-               $b = new Blog($this->myBlogId);
+               global $manager;
+               
+               $b =& $manager->getBlog($this->myBlogId);
                $message = new xmlrpcmsg(
                        'weblogUpdates.extendedPing',
                        array(
@@ -316,7 +326,9 @@ class NP_Ping extends NucleusPlugin
        
        public function pingWebloguesDotCom()
        {
-               $b = new Blog($this->myBlogId);
+               global $manager;
+               
+               $b =& $manager->getBlog($this->myBlogId);
                $message = new xmlrpcmsg(
                        'weblogUpdates.extendedPing',
                        array(
@@ -333,7 +345,9 @@ class NP_Ping extends NucleusPlugin
        
        public function pingBloggDe()
        {
-               $b = new Blog($this->myBlogId);
+               global $manager;
+               
+               $b =& $manager->getBlog($this->myBlogId);
                $message = new xmlrpcmsg(
                        'bloggUpdates.ping',
                        array(
index ce28e0c..769d911 100644 (file)
@@ -83,7 +83,7 @@
 
                $blogid = getBlogIDFromItemID($itemid);
 
-               $blog = new Blog($blogid);
+               $blog =& $manager->getBlog($blogid);
                $catid = $blog->getCategoryIdFromName($category);
 
                if ($old['draft'] && $publish) {
          * Returns a list of recent items
          */
        function _getRecentItemsBlogger($blogid, $username, $password, $amount) {
-
+               global $manager;
+               
                $blogid = intval($blogid);
                $amount = intval($amount);
 
                // 3. create and return list of recent items
                // Struct returned has dateCreated, userid, blogid and content
 
-               $blog = new Blog($blogid);
+               $blog =& $manager->getBlog($blogid);
 
                $structarray = array();         // the array in which the structs will be stored
 
                // Structure returned has dateCreated, userid, blogid and content
 
                $item =& $manager->getItem($itemid,1,1); // (also allow drafts and future items)
-               $blog = new Blog($blogid);
+               $blog =& $manager->getBlog($blogid);
 
                // get category
                $item['category'] = $blog->getCategoryName($item['catid']);
index 6bdeba1..2cadc11 100644 (file)
                }
                else
                {
-                       $blog = new Blog($blogid);
+                       $blog =& $manager->getBlog($blogid);
                        $catid = $blog->getCategoryIdFromName($category);
                }
 
        }
 
        function _getRecentItemsMetaWeblog($blogid, $username, $password, $amount) {
-
+               global $manager;
+               
                $blogid = intval($blogid);
                $amount = intval($amount);
 
                // 3. create and return list of recent items
                // Struct returned has dateCreated, userid, blogid and content
 
-               $blog = new Blog($blogid);
+               $blog =& $manager->getBlog($blogid);
 
                $structarray = array();         // the array in which the structs will be stored
 
        }
 
        function _newMediaObject($blogid, $username, $password, $info) {
-               global $CONF, $DIR_MEDIA, $DIR_LIBS;
+               global $CONF, $DIR_MEDIA, $DIR_LIBS, $manager;
 
                // - login
                $mem = new Member();
                if (!$mem->teamRights($blogid))
                        return _error(3,'Not a team member');
 
-               $b = new Blog($blogid);
+               $b =& $manager->getBlog($blogid);
 
                // - decode data
                $data = $info['bits']; // decoding was done transparantly by xmlrpclib
        }
 
        function _categoryList($blogid, $username, $password) {
+               global $manager;
+               
                // 1. login
                $mem = new Member();
                if (!$mem->login($username, $password))
                if (!$mem->teamRights($blogid))
                        return _error(3,"Not a team member");
 
-               $b = new Blog($blogid);
+               $b =& $manager->getBlog($blogid);
 
                $categorystruct = array();
 
                // 3. return the item
                $item =& $manager->getItem($itemid,1,1); // (also allow drafts and future items)
 
-               $b = new Blog($blogid);
+               $b =& $manager->getBlog($blogid);
                if ($b->convertBreaks()) {
                        $item['body'] = removeBreaks($item['body']);
                        $item['more'] = removeBreaks($item['more']);
index a68887e..07f8b57 100644 (file)
                        return _error(6,"No such item ($itemid)");
 
                $blogid = getBlogIDFromItemID($itemid);
-               $blog = new Blog($blogid);
+               $blog =& $manager->getBlog($blogid);
 
                if (!$mem->canAlterItem($itemid))
                        return _error(7,"Not allowed to alter item");
                        return _error(6,"No such item ($itemid)");
 
                $blogid = getBlogIDFromItemID($itemid);
-               $blog = new Blog($blogid);
+               $blog =& $manager->getBlog($blogid);
 
                if (!$mem->canAlterItem($itemid))
                        return _error(7, 'You are not allowed to request this information');
 
                // get item data
                $blogid = getBlogIDFromItemID($itemid);
-               $blog = new Blog($blogid);
+               $blog =& $manager->getBlog($blogid);
                $old =& $manager->getItem($itemid,1,1);
 
                return _edititem($itemid, $username, $password, $old['catid'], $old['title'], $old['body'], $old['more'], $old['draft'], 1, $old['closed']);
 
 
        function _mt_categoryList($blogid, $username, $password) {
+               global $manager;
                // 1. login
                $mem = new Member();
                if (!$mem->login($username, $password))
                if (!$mem->teamRights($blogid))
                        return _error(3,"Not a team member");
 
-               $b = new Blog($blogid);
+               $b =& $manager->getBlog($blogid);
 
                $categorystruct = array();
 
 
        function _mt_getRecentPostTitles($blogid, $username, $password, $iAmount)
        {
+               global $manager;
+               
                $blogid = intval($blogid);
                $iAmount = intval($iAmount);
 
                // 3. create and return list of recent items
                // Struct returned has dateCreated, userid, postid and title
 
-               $blog = new Blog($blogid);
+               $blog =& $manager->getBlog($blogid);
 
                $structarray = array();         // the array in which the structs will be stored
 
index 06219a4..c2c28ad 100644 (file)
 
                $item =& $manager->getItem($itemid,1,1); // (also allow drafts and future items)
 
-               $blog = new Blog($blogid);
+               $blog =& $manager->getBlog($blogid);
                if ($blog->convertBreaks())
                        $item['body'] = removeBreaks($item['body']);
 
index 992e668..462e340 100644 (file)
@@ -97,7 +97,8 @@ $s = new xmlrpc_server( $functionDefs );
   * Adds an item to the given blog. Username and password are required to login
   */
 function _addItem($blogid, $username, $password, $title, $body, $more, $publish, $closed, $catname = "") {
-       $blog = new Blog($blogid);
+       global $manager;
+       $blog =& $manager->getBlog($blogid);
        $timestamp = $blog->getCorrectTime();
        return _addDatedItem($blogid, $username, $password, $title, $body, $more, $publish, $closed, $timestamp, 0, $catname);
 }
@@ -106,6 +107,8 @@ function _addItem($blogid, $username, $password, $title, $body, $more, $publish,
   * Adds item to blog, with time of item given
   */
 function _addDatedItem($blogid, $username, $password, $title, $body, $more, $publish, $closed = '0', $timestamp, $future, $catname = "") {
+       global $manager;
+       
        // 1. login
        $mem = new Member();
 
@@ -121,7 +124,7 @@ function _addDatedItem($blogid, $username, $password, $title, $body, $more, $pub
                return _error(4,"Cannot add empty items!");
 
        // 3. calculate missing vars
-       $blog = new Blog($blogid);
+       $blog =& $manager->getBlog($blogid);
 
        // get category id (or id for default category when false category)
        $catid = $blog->getCategoryIdFromName($catname);
@@ -264,6 +267,8 @@ function _deleteItem($itemid, $username, $password) {
   * Returns a template
   */
 function _getSkinPart($blogid, $username, $password, $type) {
+       global $manager;
+       
        // 1. login
        $mem = new Member();
        if (!$mem->login($username, $password))
@@ -276,13 +281,15 @@ function _getSkinPart($blogid, $username, $password, $type) {
                return _error(3,"Not a team member");
 
        // 3. return skin part
-       $blog = new Blog($blogid);
+       $blog =& $manager->getBlog($blogid);
        $skin = new SKIN($blog->getDefaultSkin());
        return new xmlrpcresp(new xmlrpcval($skin->getContentFromDB($type),"string"));
 
 }
 
 function _setSkinPart($blogid, $username, $password, $content, $type) {
+       global $manager;
+       
        // 1. login
        $mem = new Member();
        if (!$mem->login($username, $password))
@@ -295,7 +302,7 @@ function _setSkinPart($blogid, $username, $password, $content, $type) {
                return _error(3,"Not a team member");
 
        // 3. update skin part
-       $blog = new Blog($blogid);
+       $blog =& $manager->getBlog($blogid);
        $skin = new SKIN($blog->getDefaultSkin());
        $skin->update($type, $content);