Notice

The forum is in read only mode.

Support Forum

Welcome! Support Forums have been reactivated
Welcome the Technical Support section. Help us in assisting you by providing us with a concise and descriptive elaboration of your issues. Be specific and if possible, provide us with a step-by-step instruction in replicating your problem.

Upgraded from 4.0.1 to 4.0.9 and it nearly killed my server!

8 years 8 months ago
  • Wasim's Avatar
    Topic Author
  • Wasim
  • Offline
  • Fresh Boarder
  • Posts: 4
  • Thank you received: 2
Licenses:
JomSocial Expired

Every time I upgrade there's massive performance issues. This time round it's to do with Photos and the fact your system needs to go through every single photo in the database one by one, every time a page is loaded. I don't understand why you program in half the stuff you do.

All I did was upgrade then I started getting massive system alerts and my server was about to crash. Turns out it's the following method:

com_community/models/photos.php - _getAlbums()

It runs this on every page load, or at least every profile. Gets every album from the databases then one by one gets every photo from the database (over 30,000 database calls per page load). Look at the New Relic stats!

I've had to comment out the entire method and return an empty array otherwise it crashes my site.

What's the problem? What's the use of this method and why do you feel it's required on each page load?


Attachment ScreenShot2015-08-14at12.26.55.png not found



Attachment ScreenShot2015-08-14at12.27.25.png not found



Attachment ScreenShot2015-08-14at12.27.43.png not found



public function _getAlbums($id, $type, $pagination = false, $doubleLimit = false, $limit = "", $creator = '', $sort = 'date', $excludeType = array()) {
//        $db = $this->getDBO();
//        $extraSQL = ' WHERE a.type != ' . $db->Quote('');
//
//        if (!empty($id) && $type == PHOTOS_GROUP_TYPE) {
//            $extraSQL .= ' AND a.groupid=' . $db->Quote($id) . ' ';
//            if (!empty($creator)) {
//                $extraSQL .= ' AND a.creator=' . $db->Quote($creator) . ' ';
//            }
//        } else if (!empty($id) && $type == PHOTOS_USER_TYPE) {
//            $extraSQL .= ' AND a.creator=' . $db->Quote($id) . ' ';
//            // privacy
//
//            $permission = CPrivacy::getAccessLevel(null, $id);
//            $extraSQL .= ' AND a.permissions <=' . $db->Quote($permission) . ' ';
//        }else if( !empty($id) && $type == PHOTOS_PROFILE_TYPE ){
//            $extraSQL .= ' AND a.creator=' . $db->Quote($id)
//                      .' AND a.groupid=' . $db->Quote(0) . ' AND a.eventid= '. $db->Quote(0)
//                      .' AND a.type <> '.$db->quote('profile.cover');
//        }
//
//        if(count($excludeType) > 0){
//            foreach($excludeType as $type){
//               $extraSQL .= ' AND a.type != '.$db->Quote($type).' ';
//            }
//        }
//
//        // Get limit
//        $limit = (!empty($limit)) ? $limit : $this->getState('limit');
//        $limit = ( $doubleLimit ) ? $this->getState('limit') : $limit;
//        $limitstart = $this->getState('limitstart');
//
//        // Get total albums
//        $total = $this->getAlbumCount($extraSQL);
//        $this->total = $total;
//
//        //special case for featured only, it must not be paginated
//        if($sort == 'featured'){
//            $featured = new CFeatured(FEATURED_ALBUMS);
//            $featuredAlbums = implode(',',$featured->getItemIds());
//            $order = " ORDER BY (a.`id` IN (".$featuredAlbums.")) DESC, a.id ";
//            $result = ($pagination) ? $this->getAlbumPhotoCount($extraSQL, $limit, $limitstart,$order ) : $this->getAlbumPhotoCount($extraSQL, null, null, $order);
//
//        }elseif($sort == 'featured_only'){
//            $result = $this->getAlbumPhotoCount($extraSQL, NULL, NULL,  ' ORDER BY `name` ASC');
//        }elseif($sort == 'name'){
//            $result = ($pagination) ? $this->getAlbumPhotoCount($extraSQL, $limit, $limitstart, ' ORDER BY `name` ASC') : $this->getAlbumPhotoCount($extraSQL, NULL, NULL,  ' ORDER BY `name` ASC');
//        }elseif($sort == 'hit') {
//            $result = ($pagination) ? $this->getAlbumPhotoCount($extraSQL, $limit, $limitstart, ' ORDER BY `hits` DESC') : $this->getAlbumPhotoCount($extraSQL, null, null, ' ORDER BY `hits` DESC');
//        }else{
//            $result = ($pagination) ? $this->getAlbumPhotoCount($extraSQL, $limit, $limitstart) : $this->getAlbumPhotoCount($extraSQL);
//        }

        /* filter results, album that has photos + all unpublished = not to be displayed
         * 				   album that has no photos = display
         */

//        foreach ($result as $key => $res) {
//            $temp = $this->getPhotos($res->id, null, null, true);
//            $hasPhoto = true; //assume all photo is temp
//
//            if (count($temp) > 0) {
//                foreach ($temp as $tempPhoto) {
//                    if ($tempPhoto->published == 1) {
//                        $hasPhoto = false; // this album has photos, show this album
//                        break;
//                    } elseif($tempPhoto->published == 0 && $tempPhoto->status =="delete") {
//                        $hasPhoto = false; // this album has photos, show this album
//                        break;
//                     }
//                }
//            } else {
//                $hasPhoto = false;
//            }
//
//            if ($hasPhoto) {
//                unset($result[$key]);
//            }
//        }

//        $result = [];
//
//        // Update their correct Thumbnails
//        $this->_updateThumbnail($result);
//
//        //sort the albums
//        $data = $this->sortAlbums($result,$sort);
//
//
//        // Apply pagination based on counted data
//        if($limit > count($data) && empty($this->_pagination)){
//            jimport('joomla.html.pagination');
//            $this->_pagination = new JPagination(count($data), $limitstart, $limit);
//        }else{
//            $this->_pagination = new JPagination($total, $limitstart, $limit);
//        }

        $tmpData = array();

//        if ($type == PHOTOS_PROFILE_TYPE) {
//            $type = PHOTOS_USER_TYPE;
//        }
//
//        foreach ($data as $_data) {
//            if ( ( $_data->default == 1 ) && ( $type == $_data->type ) && $sort != 'hit' ) {
//                array_unshift($tmpData, $_data);
//            } else {
//                $tmpData[] = $_data;
//            }
//        }


        return $tmpData;
    }

Attachments:
8 years 8 months ago
Licenses:

Hi, Wasim.

Thank you for reporting this issue.
I assign developer to review it.


- Instead of saying: 'it's not working', explain the problem in detail.
- Screenshots with the URL visible in them and the problem marked are more than welcome.
- Tell us how to replicate the problem, we can't fix it if we can't find it.
- Make sure that your site/server meets JomSocial System Requirements
- Make sure to setup JomSocial Cron Job
- Always provide us with access details to the backend and ftp. We need it to debug problems.
- If you have a similar problem, but a solution you found isn't working, open a new thread instead of 'merging' with an existing one.

- Use the "Thank You" feature on any post that helped you
8 years 8 months ago
Licenses:

Hi Wasim,

I marked this topic as bug. we still need to investigate this issue.
please wait for the respond from us.

Regards

8 years 8 months ago
Licenses:
JomSocial Active GURU Active Publisher Active AdAgency Active iSEO Active Socialize Active

Hello Wasim

We have tried to investigate the issue but couldn't do it properly because of environment issues.
Would it be okay for you to setup the staging shadow copy site on your server and provides the full access to it, so we can run tests and optimizations directly at the problematic site.

You can also reach me to sinisa AT ijoomla DOT com
I've be looking forward to your reply


- Don't say feature not working. Instead, explain what you tried and what was the outcome.
- When you think you found the bug, try to replicate it on a fresh Joomla.
- When looking for support always provide temporary Super Administrative access to your site. We will ask for it anyway.
- Help yourself and read documentation which can give you answers to almost all questions you may have
8 years 8 months ago
  • Wasim's Avatar
    Topic Author
  • Wasim
  • Offline
  • Fresh Boarder
  • Posts: 4
  • Thank you received: 2
Licenses:
JomSocial Expired

I don't think I'm going to do that. My server is not a guinea pig to run tests on. I'm sorry if you are unable to fix the problem without that but I'm not going to purposely cause the server load and risk downtime or reduced performance for the rest of the site. If there's anything else I can do let me know.

Moderators: Piotr Garasiński
Powered by Kunena Forum

Join 180,000 websites creating Amazing communities

JomSocial is the most complete, easy-to-use addon that turns Joomla CMS into a
full -fledged, social networking site

TRY NOW BUY NOW