[#3 cBB Follower] Error SQL, phpBB 3.0.11 y notificaciones


Due to a lack of free time, both support on this forum and extension development are currently limited.
All bugs are noted and saved for fixes, even if there are no replies to the posts.
Normal activity will resume as soon as possible.
User avatar
IvanPF
Administrator
 
Posts: 2265
Joined: Fri Jun 17, 2011 12:15 am
Location: España (Spain)
 Mon Sep 10, 2012 10:34 pm • via Web
MOD: cBB Follower 1.0.0 [Beta]

Error: Al postear o responder un mensaje se obtiene un mensaje de error SQL en phpBB 3.0.11 similar a este:
Error General
SQL ERROR [ mysql4 ]

Unknown column 'Array' in 'where clause' [1054]

SQL

SELECT u.user_id, u.user_email, u.username, u.user_lang, u.user_notify_options FROM (crack_follower_track ft) LEFT JOIN crack_users u ON (u.user_id = ft.user_id) WHERE ft.follow_id = 2 AND u.user_id NOT IN (Array) AND u.user_type IN (0, 3)


Solución:
1. Abrir /follower/includes/functions_follower.php
2. Buscar:
Code: Select all
   if(!$sql_ignore_users)
   {
      // Get banned User ID's
      $sql = 'SELECT ban_userid
         FROM ' . BANLIST_TABLE . '
         WHERE ban_userid <> 0
            AND ban_exclude <> 1';
      $result = $db->sql_query($sql);
   
      $sql_ignore_users = ANONYMOUS . ', ' . $user->data['user_id'];
      while ($row = $db->sql_fetchrow($result))
      {
         $sql_ignore_users .= ', ' . (int) $row['ban_userid'];
      }
      $db->sql_freeresult($result);
   }

3. Reemplazar por:
Code: Select all
   if(empty($sql_ignore_users))
   {
      $sql_ignore_users = array();

      if(version_compare(PHPBB_VERSION, '3.0.10', '>'))
      {
         if (!function_exists('phpbb_get_banned_user_ids'))
         {
            include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
         }

         $sql_ignore_users = phpbb_get_banned_user_ids();
      }
      else
      {
         // Get banned User ID's
         $sql = 'SELECT ban_userid
            FROM ' . BANLIST_TABLE . '
            WHERE ban_userid <> 0
               AND ban_exclude <> 1';
         $result = $db->sql_query($sql);
         while ($row = $db->sql_fetchrow($result))
         {
            $user_id = (int) $row['ban_userid'];
            $sql_ignore_users[$user_id] = $user_id;
         }
         $db->sql_freeresult($result);
      }
      
      $sql_ignore_users[ANONYMOUS] = ANONYMOUS;
      $sql_ignore_users[$user->data['user_id']] = $user->data['user_id'];
   }

4. Buscar:
Code: Select all
   $sql_ary['WHERE'] .= " AND u.user_id NOT IN ($sql_ignore_users)
      AND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')';

5. Reemplazar por:
Code: Select all
   $sql_ary['WHERE'] .= ' AND ' . $db->sql_in_set('u.user_id', $sql_ignore_users, true) . '
      AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')';

6. Buscar:
Code: Select all
      $notify_rows[$row['user_id']] = array(
         'user_id'         => $row['user_id'],

7. Reemplazar por:
Code: Select all
      $user_id = (int)$row['user_id'];

      $notify_rows[$user_id] = array(
         'user_id'         => $user_id,

8. Buscar:
Code: Select all
         else if($follower->notify($mode, 'email', $row['notify_options']))
         {
            $email_users[] = $row;
         }

9. Añadir después:
Code: Select all
         // Dont send mention notification if previous notification was sended
         if(in_array($mode, array('posts', 'topics', 'replies')))
         {
            $sql_ignore_users[$user_id] = $user_id;
         }

10. Buscar:
Code: Select all
   // Send mention notification
   if(in_array($mode, array('posts', 'topics', 'replies')))
   {
      // Dont send mention notification if previous notification was sended
      if(!empty($notify_rows))
      {
         $sql_ignore_users .= implode(', ', array_keys($notify_rows));
      }

      follower_notification('mentions', $follower->mention_ids, false, $sql_ignore_users);
   }

11. Reemplazar por:
Code: Select all
   // Send mention notification
   if(in_array($mode, array('posts', 'topics', 'replies')))
   {
      follower_notification('mentions', $follower->mention_ids, false, $sql_ignore_users);
   }


12. Abrir /follower/follower.php
13. Buscar:
Code: Select all
   function notification($mode, $item_ids, $data = false, $sql_ignore_users = '')
   {
      global $phpbb_root_path, $phpEx;

      if(!function_exists('follower_notification'))
      {
         include($phpbb_root_path . 'follower/includes/functions_follower.' . $phpEx);
      }
      
      return follower_notification($mode, $item_ids, $data, $sql_ignore_users);
   }

14. Reemplazar por:
Code: Select all
   function notification($mode, $item_ids, $data = false, $sql_ignore_users = false)
   {
      global $phpbb_root_path, $phpEx;

      if(!function_exists('follower_notification'))
      {
         include($phpbb_root_path . 'follower/includes/functions_follower.' . $phpEx);
      }
      
      /* Compatibility with old phpbb versions */
      if($sql_ignore_users !== false && !is_array($sql_ignore_users))
      {
         $ignore_users = explode(', ', $sql_ignore_users);
         $sql_ignore_users = array();
         
         foreach($ignore_users as $user_id)
         {
            $user_id = (int)$user_id;
            $sql_ignore_users[$user_id] = $user_id;
         }
      }
      
      return follower_notification($mode, $item_ids, $data, $sql_ignore_users);
   }

Who is online

Users browsing this forum: No registered users and 0 guests