OSDN Git Service

FIX: <%existsNewPlugin%>がすべてのプラグインのリストを表示するバグの修正
authorsakamocchi <o-takashi@sakamocchi.jp>
Mon, 7 May 2012 13:37:16 +0000 (22:37 +0900)
committersakamocchi <o-takashi@sakamocchi.jp>
Mon, 7 May 2012 13:37:16 +0000 (22:37 +0900)
SQL文とその評価のミス。ついでにより効率のよいロジックに書き換えた。

nucleus/libs/AdminActions.php

index 0faf855..a2b1fa9 100644 (file)
@@ -5719,24 +5719,28 @@ class AdminActions extends BaseActions
        {
                global $DIR_PLUGINS;
                
-               $candidates = array();
+               $query = "SELECT * FROM %s;";
+               $query = sprintf($query, sql_table('plugin'));
+               $res  = DB::getResult($query);
+               
+               $installed = array();
+               foreach( $res as $row )
+               {
+                       $installed[] = $row['pfile'];
+               }
+               
                $files = scandir($DIR_PLUGINS);
                
+               $candidates = array();
                foreach ( $files as $file )
                {
-                       if ( preg_match("#^NP_(.*)\.php$#", $file, $matches) )
+                       if ( preg_match("#^(NP_.*)\.php$#", $file, $matches) )
                        {
-                               $name = $matches[1];
-                               $query = "SELECT * FROM %s WHERE pfile=%s;";
-                               $query = sprintf($query, sql_table('plugin'), DB::quoteValue("{NP_{$name}"));
-                               $res  = DB::getResult($query);
-                               
-                               if ( $res->rowCount() == 0 )
+                               if ( !in_array($matches[1], $installed) )
                                {
-                                       $candidates[] = $name;
+                                       $candidates[] = $matches[1];
                                }
                        }
-                       continue;
                }
                $this->newPlugCandidates = $candidates;
                return (count($candidates) > 0);