2.8.4 logs

User avatar
axew3
w3all User
w3all User
Posts: 2883
Joined: Fri Jan 22, 2016 5:15 pm
Location: Italy
Contact:

Re: 2.8.4 logs

Post by axew3 »

In the while 2.8.4 will be published very soon, probably today!
maybe today!

Code: Select all

private static function last_forums_topics($ntopics = 10){
has been finally fixed to get only required values, and shortened to be faster, the new version become:

Code: Select all

private static function last_forums_topics($ntopics = 10){

# Note that userID 2 in phpBB goes into default phpBB guest user group
# because $w3all_phpbb_usession is empty for this uid (excluded)
 global $w3all_phpbb_connection,$w3all_phpbb_usession,$w3all_config,$w3all_exclude_phpbb_forums,$w3all_wlastopicspost_max,$w3all_lasttopic_avatar_num,$w3all_get_topics_x_ugroup,$w3all_heartbeat_phpbb_lastopics_num;

 if( empty($w3all_phpbb_connection) )  return; 

 $topics = array();
 $ntopics0 = $w3all_wlastopicspost_max > $w3all_lasttopic_avatar_num ? $w3all_wlastopicspost_max : $w3all_lasttopic_avatar_num;
 $ntopics  = $ntopics0 > $ntopics ? $ntopics0 : $ntopics;
 $ntopics  = $w3all_heartbeat_phpbb_lastopics_num > $ntopics ? $w3all_heartbeat_phpbb_lastopics_num : $ntopics;
 $ntopics = $ntopics > $ntopics0 ? $ntopics : 10;
 $topics_x_ugroup = $no_forums_list = '';

 if($w3all_get_topics_x_ugroup == 1){

  if (!empty($w3all_phpbb_usession)) {
    $ug = $w3all_phpbb_usession->group_id;
    $ui = $w3all_phpbb_usession->user_id;
   } else {
     $ug = $ui = 1; // the default phpBB guest user group
    }

  # 16 ROLE_FORUM_NOACCESS into acl_roles table
  # get all forums ids which the user have no permissions to read
  $gaf = $w3all_phpbb_connection->get_results("SELECT AG.forum_id
    FROM ".$w3all_config["table_prefix"]."acl_groups AS AG
    JOIN ".$w3all_config["table_prefix"]."user_group AS UG ON( UG.user_id = ".$ui."
     AND UG.group_id = AG.group_id
     AND AG.auth_role_id = 16 )");

   if(!empty($gaf)){
      $gf = '';
       foreach( $gaf as $v ){
        $gf .= $v->forum_id.',';
       }
    $gf = substr($gf, 0, -1);
    $topics_x_ugroup = "AND T.forum_id NOT IN(".$gf.")";
   }
 }

  if ( preg_match('/^[0-9,]+$/', $w3all_exclude_phpbb_forums ))
  {
    $exp = explode(",", $w3all_exclude_phpbb_forums);
    $exc_forums_list = '';
     foreach($exp as $k => $v){
      $exc_forums_list .= "'".$v."',";
     }
    $nfl = substr($exc_forums_list, 0, -1);
    $exc_forums_list = "AND T.forum_id NOT IN(".$nfl.")";
  } else { $exc_forums_list = ''; }

      $topics = $w3all_phpbb_connection->get_results("SELECT
       T.topic_id,T.forum_id,T.topic_title,T.topic_last_post_id,T.topic_last_poster_id,T.topic_last_poster_name,T.topic_last_post_time,
       P.post_id,P.topic_id,P.forum_id,P.poster_id,P.post_time,P.post_username,P.post_subject,P.post_text,P.post_visibility,
       U.user_id,U.username,U.user_email
       FROM ".$w3all_config["table_prefix"]."topics AS T
       JOIN ".$w3all_config["table_prefix"]."posts AS P on (T.topic_last_post_id = P.post_id and T.forum_id = P.forum_id)
       JOIN ".$w3all_config["table_prefix"]."users AS U on U.user_id = T.topic_last_poster_id
       WHERE T.topic_visibility = 1
       ".$exc_forums_list."
       ".$topics_x_ugroup."
       AND P.post_visibility = 1
       ORDER BY T.topic_last_post_time DESC
       LIMIT 0,$ntopics");

     $t = is_array($topics) ? serialize($topics) : serialize(array());
     if(!defined("W3PHPBBLASTOPICS")){
      define( "W3PHPBBLASTOPICS", $t ); // see also wp_w3all.php and wp_w3all_assoc_phpbb_wp_users in this class
     }

    return $topics;
}
There are two points to know (and maybe to be fixed in the future) about last topics:
1) the serialization of the resulting array, that since Php 7.2 (if not wrong) is not necessary because a CONSTANT can be array.
But it is really a secondary aspect soon resolved on next.
2) the fact that the new added Last Topics block widget for Gutenberg, seem to be hard to be hooked so to know earlier, the number of posts for each widget (all widgets that could co-exists into a page), and so to calculate and know the max num of posts to be retrieved, useful to not call the last topics function more times to get different number of topics/posts for each widget.
This seem very hard to be resolved, if not adding an option where an admin could put the max number of topics that will be retrieved.

Anyway the point has been fixed re-calling the function with the proper num of topics to be retrieved, whenever, and only if, into a page/post, there is more than one Last Posts widget, and in the case that the first instance, that retrieve posts through the Last Topics function, call the function with a num of posts that's minor, respect the second widget that will call same function on same page/post.

[EDITED]
User avatar
axew3
w3all User
w3all User
Posts: 2883
Joined: Fri Jan 22, 2016 5:15 pm
Location: Italy
Contact:

Re: 2.8.4 logs

Post by axew3 »

Just released 2.8.4!

Code: Select all

= 2.8.4 =
*Release Date - 22 Apr, 2024*
* Fix: option 'Retrieve posts on Last Topics Widget based on phpBB user's group' to return the correct result, and the option has been improved to become: Display topics/posts on Shortcodes and Widgets based on the phpBB user's groups permissions
* Fix: improve the 'private static function last_forums_topics($ntopics = 10)' so to get only required values and make it faster. Fix and remove the code on same function.
* Add: Gutenberg w3all 'phpBB last topics block' widget
* Fix: (secondary) security bug into the function 'public static function w3all_bbcodeconvert($text)'
* Fix: minor fixes
* Logs: https://www.axew3.com/w3/forums/viewtopic.php?t=1870
Post Reply