• Resolved Marcus Fridholm

    (@marcusfridholm)


    I chose this plugin for an intranet I’m working on. It seemed simple and clear, and in general to be doing what I needed.

    I added the groups I needed, just short of 40, then categories to match them, and parent pages for each. Roughly 40 categories and top-level pages plus another 10 or so subpages.

    Since the groups aren’t hierarchical, a lot of pages and categories have more than group assigned to them, on average two.

    I now started adding posts to a couple of the categories, about 70 posts in all.

    While I was working the system got slower and slower, not so much in the admin area as in the front.

    So I installed debug objects to see wtf was going on. And noted that on the same page where I had 18 (eighteen) queries without UAM, i had 10302 (ten thousand threehundred and two queries I sh*t you not!) with the plugin active.

    Total query time: 1 392,1ms for 10302 queries (1,392127990722656s)
    Page generated in 4 000,0ms; (4,6721889972686767578125s); 65,20% PHP; 34,80% MySQL

    In reality that means going from a page served in less than half a second to about four seconds on localhost and eight seconds on my actual host. Activating W3 total cache, the time got down to seven seconds, so that is still faaaaar too slow.

    I sat down and started to analyze the reported queries, to try to get why the sh*t hit the fan that way, and it turns out it is probably an iteration/recursivity problem.

    That is, rather than doing a single query and using the result to filter what is accessible or not, it asks for each and every restrictable object. In some cases it makes the same query three or more times per object almost consecutively.

    Like this:

    Time: 0.2ms (0.00022101402282715s)
    Query: SELECT object_id as id
    FROM wp_uam_accessgroup_to_object
    WHERE group_id = 1
    AND object_type = ‘category’
    Function: UamUserGroup->getObjectsFromType()

    Time: 0.2ms (0.00017690658569336s)
    Query: SELECT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = ‘category’ AND t.term_id = 1 LIMIT 1
    Function: get_term()

    Time: 0.2ms (0.00018811225891113s)
    Query: SELECT object_id as id
    FROM wp_uam_accessgroup_to_object
    WHERE group_id = 1
    AND object_type = ‘category’
    Function: UamUserGroup->_getAssignedObjects()

    Time: 0.1ms (0.00014400482177734s)
    Query: SELECT COUNT(*)
    FROM wp_term_relationships AS tr,
    wp_term_taxonomy AS tt
    WHERE tr.object_id = ‘247’
    AND tt.term_id = ‘1’
    AND tr.term_taxonomy_id = tt.term_taxonomy_id
    AND tt.taxonomy = ‘category’
    Function: UamUserGroup->_isPostInCategory()

    Time: 0.2ms (0.00021100044250488s)
    Query: SELECT object_id as id
    FROM wp_uam_accessgroup_to_object
    WHERE group_id = 1
    AND object_type = ‘post’
    Function: UamUserGroup->_getAssignedObjects()

    And so on… for ever and ever and ever.

    So my choices are to accept the performance hit, go through and debug the 4000 lines of code in the plugin, or start over with another plugin.

    Alternative one is probably a deal-breaker, since either the customer or the customers host will flog me if I let this go live in its current condition.

    Alternative two would be doable if I can be fairly sure of success. The cost would be time, which I can pay if it works and not if it doesn’t.

    The third alternative means starting over, which is very unappealing but might be what it comes down to in the end.

    What I would like is for the plugin author to test and see if he can recreate the problem, and share what might be the offending method, if there are any workarounds and whether it is a simple fix or means a total rewrite.

    If it is something he can recreate and if it is doable to fix it within a reasonable time-frame, I am available to help.

    https://www.ads-software.com/extend/plugins/user-access-manager/

Viewing 15 replies - 46 through 60 (of 83 total)
  • amy news?

    Hello

    wanted to join the chat. We are in the process of deciding access plugins for WordPress and the issue discussed here is a select-stopper until resolved.
    I would like to know, if we have a stable status in the trunk and when there could be a fix expected?

    many thanks

    Updates
    The setup is around 300 posts, 4 users, 3 User groups. Before The site went slow as h-ll.

    After testing the last dev version from the link above, a huge improvement, and all settings seems to work as expected. But our settings are very simple.

    However, in this test I just added, and removed som testpages, and a more extensive check will be performed this week.

    So far, the lock recursive is a “question-mark” for us. Right now we are FORCING ALWAYS USERS to check EACH POST as wanted restricted settings. Means, each post has a “saved” choice. As long as that works, we are fine. This is a standard handling for most CMS. The post have the same rules even if the post moves to another category. A post and content should not be trusted by its parent. Today, information/ a post/ has a life in so many leaks, like rss, sharing urls, iphone auto stuff bla bla.

    This policy makes it easier for us to test and track any issues, to be consistently in the save-process.

    And for @shonu situation is similar for mine.

    We are on Hold with some internal client network sites, waiting to make a final call about using this plugin. And for any other readers, here is wy we concider (worth waiting for) using User Access Manager as main plugin. (Hopefully the author get feedback for a god work too):

    UAM is easy (as it can be) to use, understand and logic for clients. It doesnt clutter the backend as som many “free” versions does.

    Other tested plugin like s2member cant “hide” restricted areas, menu items and cross links. They just “redirect” clicked link (protecting urls). There is a setting to “hide wordpress components” but it does not work and they have tickets about this since 3 yars ago – they are not interested to develope this.

    This plugin has nothing to do with payment gateways and that stuff. It is a plain content access management. Thats wy so few solutions aside UAM is out there.

    Most important: This plugin hides the menu items, removes the widget connection values like “Last comment by” on a resttricted post. The login out, redirect, register and notification fiters and hooks, works without interfearance. Many other plugin “takes over” a lot of stuff, this does not.

    This plugin can handle restrictions between editors as well as standard roles and caps without mess. The plugin User role manager works fine together with this API.

    Post this browser script, Postie (email content to restricted categories) works. And finally, this plugin hides “subscriptions choices” for restricted posts and categories in ex WP MAILPRESS setup/ lists (newsletters). The latter with a few tweaks, but this turns wordpress to a complete project management system.

    UAM has not any hooks/ documentation (its a free plugin), but the sourcecode is not so hard to “spit out in templates” as long as you find the access to the main object. For example, a user with ok to view secret content, needs to be shure that the comment are restricted. We added textlines like “This page is restricted, only users with the same capabilities like yours, can view the comment (Personal trainers, and booking gym workers)”. And much more… To make the user experiance better. All other plugins we tried was to complex to just get output to the templates.

    THIS is wy we are giving this a chance as long as the plugin does not slow down the site more then necessary.

    Keep in mind, all access system will slow down the site. Don run woocommerce and UAM intranet on the same install…

    Summary, the idea and main implemention API idea seems to work fine with wp-core, but I hope, hope, hope that the idea not have the renundant query problem/ speed as a cost for UAM to do the great job.

    Finally, a note, never “rely” on auto written htaccess restriction solutions. It is safe, but ajaxcalls, back up system plugins and more WILL stop working, break image links and much more. Do this “download restriction, etc etc” ouside a member level access system.

    Therefore, I suggest the author to move away the UAM functions for images, attachments. And concentrate the plugin to user/ content front end multilevel/ group restriction for post and pages/ tax to work first.

    / Jonas

    Update, dev version is broken

    I just tested the linked development version again (in this thread). This time on a new clean install, latest WP version. All settings get lost after a while.

    – Saving a single post with a unique access for a group, just dissapear when working on other posts.

    – All the categories assigments to groups get lost, cant findout when. Even if they contain posts or are empty.

    I can see that the groups themselfs looses rules and the user settings get lost too. So maybe it is a top-level problem, not actually an access level bug.

    I tried to track by :
    – Lock recursive shifting on and off, (and wait, working a while)

    Very sad.

    Thread Starter Marcus Fridholm

    (@marcusfridholm)

    GM_Alex, if you want this plugin to survive, now is the time to step up and do something about the issues.

    Right now:

    • You have problems with the dev version losing settings.
    • There are still problems with the plugin being glacially slow.
    • There are problems with the plugin failing strict standards in wp 3.7

    The last point is rather simple to fix, it is mainly problematic pass-by-reference issues, that are easy to hunt down and kill.

    I think you have a choice here:
    You can tell us you won’t do it. That’s fair enough, we haven’t paid for this. It would be good to know though.

    You can tell us you need someone to help you/take over. That is actually a pretty good idea if you feel it is just too much. If someone else could be briefed on your code, rather than having to deconstruct it, passing the torch would be rather easier.

    You can step up and just do it. That is what everyone is hollering about and the basis for a successful plugin.

    Right now we’re in limbo, because this is THE uam-plugin that is the most intuitive and complete, the most promising one. It could be truly brilliant.

    So basically we’re waiting, rather than doing the heavy lifting ourselves or starting to look elsewhere.

    Hard words, but I agree, some kind of hint and update about the future of this plugin would be great.

    Right now we’re in limbo, because this is THE uam-plugin that is the most intuitive and complete, the most promising one. It could be truly brilliant.

    Well, first loss is me. We (an organisation) have decided for another plugin, with the commercial option taken as well. Sad.
    If this plugin ever progresses again, I might consider it again elsewhere, but for now.

    All the best

    Thread Starter Marcus Fridholm

    (@marcusfridholm)

    I’m leaving it in, in one of my projects where backing out this late in the game would be too painful. Looking in the rear-view mirror, I should have switched horses at a far earlier point in time.

    But as I said, compared to the others this one seems more relevant and intuitive. I’ve kept my hopes up for a bit too long.

    Thread Starter Marcus Fridholm

    (@marcusfridholm)

    At last I got my boss’ go ahead too look into this plugin for real. I’ve spent about 10 hours on it.

    My results so far is curtailing the queries on the admin page (list) view on the site where I use it from about 11000 to about 4500. Even though I’m using multidimensional arrays with approx 500 entries, I’ve still noted some lessening of the memory footprint and quite a speed difference.

    Basically I’ve introduced a public static array of all objects and one of all groups, together with a method to simulate DB-queries. Then I replaced all SELECT-queries polling the UAM tables. From one query per group assignment per object and then some other miscellaneous ones, I’m now using only two queries to the UAM-tables, one each.

    The reasons for the remaining 4400 or so extraneous queries, are a lot of repetitive polling of wordpress objects, they’re truly a bit too costly to use that way.

    If anyone else would like to test my changes, I’m going to keep it on our demoserver for a little while. If you want to see what I’ve done, run a diff to compare it with the original.
    Most changes are in UserAccessManager.class.php and UamUserGroup.class.php.

    Here’s the link

    If anyone feels up to doing some more clean-up, look at how I’ve introduced public static arrays in the UserAccessManager-class and how I fill them up with data on the get go. As long as you keep it to static stuff, you can use the self::method, self::variable, UserAccessManager::method and UserAccessManager::variable instance-less calling of arrays and methods. Actually you can do that anyways, but then you will get strict-mode-warnings.

    Some cleanup would actually be good, since I haven’t actually deleted all the code that is no longer used, some yes, but not all.

    I’m going to test if my changes are “good enough” for my purposes, if so I won’t do any more work on it. Otherwise… “I’ll be back” ??
    Please holler if there are bugs and such in my implementation, I make no promises whatsoever, but if I make changes I’ll share.

    Thread Starter Marcus Fridholm

    (@marcusfridholm)

    Oh one more note.

    The page-list in the admin is the heaviest of all afaik. I tested the same page I tested when this started, then I got:

    Total query time: 1 392,1ms for 10302 queries (1,392127990722656s)
    Page generated in 4 000,0ms; (4,6721889972686767578125s); 65,20% PHP; 34,80% MySQL

    Now I get:

    Total query time: 578,2ms for 3154 queries (0,578152656555176s)
    Page generated in 1 000,0ms; (1,6872680187225341796875s); 42,18% PHP; 57,82% MySQL

    Definitely following this with piqued interest as well. I couldn’t figure it out – we have several sites that use UAM, and only one of them was encountering the extreme slowness issue. (We determined it was UAM by disabling all plugins, and then reactivating each of them one by one until it slowed down again. UAM was the culprit). Then, when comparing the slowed site with one of other sites that loaded fine; the slow site has 223 posts, the site with no performance issues had 19. So, it does appear that post count / what Marcus is referencing above (the programming stuff starts to go WAY over my head) is what is affecting the slow loading of the site in question for us.

    Marcus, my question to you is: If I install the version of the plugin that you are working on, provided in the link above, A) will it keep my existing user groups / post assignments in tact (I assume so, but want to be sure) and B) Even though it’s still a work in progress, am I reading correctly that it should improve the site’s performance, at least to some extent?

    I also wish to echo what many here have said. We really love the overall functionality of this plugin – it’s perfect for the type of “board members only” areas that some of our clients require. We had never run into this performance issue before, so I’m glad someone is digging in to the root of the issue. And Marcus, as a user of this plugin, I would like to also offer my thanks to you for digging in and trying to remedy the issue at hand, from all of those of us who have very little programming knowledge. This plugin is integral to several of our sites, so it’s nice to see some progress being made towards a solution.

    I’ll keep watching the thread for sure, hoping at some point there is a version of the plugin that truly completely resolves the issue.

    Thanks!

    Thread Starter Marcus Fridholm

    (@marcusfridholm)

    I finished up today, which means submitting this here now is for more than just me being able to test the changes.

    Having said that, the only parts changed are the parts that read from the UAM tables, not the ones that inserts, updates or deletes rows in the tables.

    That means in real life, that while there might be bugs, there shouldn’t be any of the sort you’re afraid of. If worst comes to worst stuff may be visible that shouldn’t or invisible when they should be seen.

    I’ve tried it over two installs with radically different setups of groups and plugins. They were on the same server though, so I can’t really claim my testing has been thorough.

    Even so I haven’t seen any signs of visibility bugs. I had a few while coding and testing as expected, but fewer than I feared and I found them all.

    The only way to be sure is to test. If you can, clone the site locally or on a private server and test it out before you go live. I’d love to hear your results.

    Thread Starter Marcus Fridholm

    (@marcusfridholm)

    It should indeed improve performance. I can’t say for sure how the memory footprint will look on all installations, arrays are after all memory intensive. But then objects are even more memory intensive and the plugin created plenty of those…

    Ok, great, thank you for the response. So, I downloaded from your link above just before I posted earlier (about an hour ago). Did you post a newer version to the link above? Do I need to download it again?

    I will definitely try testing on one of our test servers first. Again, your assistance in this is very much appreciated. Eager to see if this version helps – sounds very promising.

    Thanks!

    Ok, shoot. Just did try Marcus’ version of the plugin on our test server (WP up to date, all other plugins up to date, Twenty Thirteen theme activated to start with), and I’m getting a php error:

    Parse error: syntax error, unexpected '[' in /home/domains/public_html/wpdev/wp-content/plugins/user-access-manager/class/UamUserGroup.class.php on line 494

    Again, my php knowledge is extremely limited, so I’m not sure why this is an error. ??

Viewing 15 replies - 46 through 60 (of 83 total)
  • The topic ‘Repeated queries and scalability’ is closed to new replies.