Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have a dev install of Drupal 7 RC1 with Simple Access HEAD installed. There's some test content I created before enabling Simple Acess. I haven't changed any settings in Simple Access, just left it as the defaults.
When I try to edit a page created by a non-admin user, using that same user, it gives me this error:
Fatal error: Call to a member function condition() on a non-object in /d7/sites/all/modules/simple_access/simple_access.module on line 657
Nothing else is displayed, just the error.
How can I fix this?
Comment | File | Size | Author |
---|---|---|---|
#28 | 991956.patch | 889 bytes | gordon |
#13 | 991956-14-fix-innerJoin-chain.patch | 985 bytes | kim.pepper |
#10 | fix-innerJoin-chain-991956-10.patch | 1.06 KB | Anonymous (not verified) |
#6 | fix-innerJoin-chain-991956-6.patch | 898 bytes | anj |
Comments
Comment #1
jerrac CreditAttribution: jerrac commentedI forgot to mention that I can edit things just fine as an admin.
Comment #2
ctpmp CreditAttribution: ctpmp commentedI'm seeing this also trying to add content as a non-admin. The problematic code is:
The innerJoin method does not return an object that can be chained like this.
http://api.drupal.org/api/drupal/includes--database--select.inc/function...
Changing to this seems to work
Comment #3
Joe90 CreditAttribution: Joe90 commentedIs the workaround by ctpmp above considered as the fix? If so it's not doing it for me? I am using Simple Access and forum Access on Drupal 7
I have the need for private forums and private blogs. No non-admin users can create a blog entry or forum post and get the error page as above:
[code]Fatal error: Call to a member function condition() on a non-object in /d7/sites/all/modules/simple_access/simple_access.module on line 657[/code]
Admin can create blog and forum posts OK (though strangely non of the boxes are ticked to do this in permissions for Admin!)
Tried ctpmp's fix but the errors persisted, complaining about last line in the fix.
Please help / advise.
Comment #4
idealworldweb CreditAttribution: idealworldweb commentedctpmp's fix is working for me, as I had the same problem on non-admin members with the correct permissions to edit pages. Thanks
Comment #5
kscott22 CreditAttribution: kscott22 commentedI hate to mess with module code, but ctpmp's suggestion in #2 worked for me. Thanks!
Comment #6
anj CreditAttribution: anj commentedThe fix in #2 worked for me too. Here it is in patch form.
Comment #7
andresp CreditAttribution: andresp commentedthis fix works for me too
Comment #8
drifter CreditAttribution: drifter commentedThe proposed patch works for me, thanks!
Comment #9
anj CreditAttribution: anj commentedI just realised that this bug stops anyone from creating any content under D7. Upgrading to 'critical' and marking as 7.x-2.0-beta1 as I just re-tested against the patch against that release and it work as expected.
Comment #10
Anonymous (not verified) CreditAttribution: Anonymous commentedadding patch because current doens't work in my drush make installation
Comment #11
simon_w108 CreditAttribution: simon_w108 commentedwhoah! this is still broken in the main version?!?
ctpmp's fix does work, but the penultimate line is wrong. correction below:
Comment #12
azinck CreditAttribution: azinck commented#11 works. Trivial fix, let's get this committed!
Comment #13
kim.pepperThe problem is incorrect usage of ->innerJoin() It doesn't return a SelectQueryInterface
@see http://api.drupal.org/api/drupal/includes%21database%21select.inc/functi...
The following patch combines the fixes in #10 and #11
Comment #14
Jason Dean CreditAttribution: Jason Dean commented#13 works for me - thanks! (phew)
Comment #15
dianacastillo CreditAttribution: dianacastillo commentedCan you put this into the latest module please? or is it already there?
Comment #16
dianacastillo CreditAttribution: dianacastillo commentedI get this when an editor tries to create content as well:
Fatal error: Call to a member function condition() on a non-object in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\pn\sites\all\modules\simple_access\simple_access.module on line 637
Comment #17
dianacastillo CreditAttribution: dianacastillo commentedComment #18
dianacastillo CreditAttribution: dianacastillo commentedI'm confused, because in this patch you have something different than what is in the module now:
while ($group = $result->fetchAssoc(PDO::FETCH_ASSOC)) {
$groups[$group['gid']] = $group;
$groups[$group['gid']]['access'] = $default_access;
}
Comment #19
dianacastillo CreditAttribution: dianacastillo commentedI get these errors when I applied the patch
Notice: Undefined variable: roles in simple_access_group_select() (line 628 of C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\pn\sites\all\modules\simple_access\simple_access.module).
Warning: Invalid argument supplied for foreach() in DatabaseCondition->compile() (line 1854 of C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\pn\includes\database\query.inc).
PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')) GROUP BY g.gid' at line 2: SELECT g.gid AS gid FROM {simple_access_groups} g INNER JOIN {simple_access_roles} r ON g.gid = r.gid WHERE (rid IN ()) GROUP BY g.gid; Array ( ) in simple_access_group_select() (line 630 of C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\pn\sites\all\modules\simple_access\simple_access.module).
Comment #20
dianacastillo CreditAttribution: dianacastillo commentedWhen I give the editor permissions to "Administer Content " in the permissions page , this error goes away (without applying the patch which doesnt work for me)
Comment #21
Simon Georges CreditAttribution: Simon Georges commentedClosing #1916384: non admin cannot add content as a duplicate of this one.
Comment #22
Simon Georges CreditAttribution: Simon Georges commentedClosing #1660162: I found a bug with Drupal 7 code. Unable to edit posts. as a duplicate of this one.
Comment #23
chertzog#13 Works for me.
Comment #24
gordon CreditAttribution: gordon commentedThis still needs some work. I don't like how this fix has been done.
Comment #25
kim.pepper@gordon Can you please elaborate? You don't like the syntax? or the approach?
I believe the error was due to incorrect usage of the api. Happy to discuss alternate approaches. :-)
Kim
Comment #26
gordon CreditAttribution: gordon commentedI understand, I am going to have a look at this tomorrow and clean up the code. Basically I would prefer to chain as much as possible and them access the query to add the joins.
Comment #27
dianacastillo CreditAttribution: dianacastillo commentedthis patch only created more problems for me.
Comment #28
gordon CreditAttribution: gordon commentedI have done some tidy up on the patch so it is cleaner, but basically the same patch.
I am wondering if the innerJoin() issue should be raised as an issue, since it can't be chained.
Comment #29
gordon CreditAttribution: gordon commentedI have committed this to dev.
@dianacastillo what were the problems which you were having with this patch?
Comment #30
gordon CreditAttribution: gordon commentedComment #31
kim.peppergroupBy() returns a SelectQuery object, so you could just put the join at the end of that chain.
http://api.drupal.org/api/drupal/includes%21database%21select.inc/functi...
K
Comment #32
dianacastillo CreditAttribution: dianacastillo commentedI posted the errors I got with this patch previously #19 http://drupal.org/node/991956#comment-7062164
Comment #33
gordon CreditAttribution: gordon commentedI am not sure what the problem is there because $roles can never be uninitilised.
$user->roles is always populated with a value, and it can never be empty either.
If you are still getting this issue, please raise another issue.
Comment #34
dianacastillo CreditAttribution: dianacastillo commentedHi, i have not tried the patch again because when I give the editor permissions to "Administer Content " in the permissions page , this error goes away . thanks