Projet

Général

Profil

Révision c169e7c4

Ajouté par Assos Assos il y a presque 10 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/advanced_forum/includes/core-overrides.inc
90 90

  
91 91

  
92 92
  // Return a cached forum tree if available.
93
  if (!isset($tid)) {
93
  if (empty($tid)) {
94 94
    $tid = 0;
95 95
  }
96 96
  if (isset($cache[$tid])) {
......
137 137
    $_forums = i18n_taxonomy_localize_terms($_forums);
138 138
  }
139 139

  
140
  if (count($_forums)) {
140
  if ($cached = cache_get('adv_forum_counts' . $tid, 'cache')) {
141
    if ($cached->expire > time()) {
142
      $counts = $cached->data;
143
    }
144
  }
145
  if (count($_forums) && empty($counts)) {
141 146
    $query = db_select('node', 'n');
142 147
    $query->join('node_comment_statistics', 'ncs', 'n.nid = ncs.nid');
143 148
    $query->join('forum_index', 'f', 'n.nid = f.nid');
......
173 178
        ->addTag('node_access')
174 179
        ->execute()
175 180
        ->fetchAllAssoc('tid');
181
    cache_set('adv_forum_counts' . $tid, $counts, 'cache', time() + 60*60); //1 hour
176 182
  }
177 183

  
184
  // get last nodes with comments for subquery SELECT optimization
185
  $subquery = db_select('node_comment_statistics', 'lnsc')
186
    ->fields('lnsc', array('nid'))
187
    ->distinct()
188
    ->orderBy('last_comment_timestamp', 'DESC')
189
    ->range(0, 1000); // should be moved to options or additionally calculated elsewhere
190

  
178 191
  foreach ($_forums as $forum) {
179 192
    // Determine if the child term is a container.
180 193
    if (in_array($forum->tid, variable_get('forum_containers', array()))) {
......
193 206

  
194 207
    // Query "Last Post" information for this forum.
195 208
    $query = db_select('node', 'n');
209
    $query->join($subquery, 'lastnodes', 'n.nid = lastnodes.nid');
196 210
    $query->join('forum_index', 'f', 'n.nid = f.nid AND f.tid = :tid', array(':tid' => $forum->tid));
197 211
    $query->join('node_comment_statistics', 'ncs', 'n.nid = ncs.nid');
198 212
    $query->join('users', 'u', 'ncs.last_comment_uid = u.uid');

Formats disponibles : Unified diff