-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[2.4] Call to a member function getChildren() on a non-object #25
Comments
I'm going to summon a few Symphonists, sorry in advance! (@designermonkey @brendo @nitriques @michael-e @nilshoerrmann) - as I really need to use this extension and it seems completely unmaintained - not sure how likely it is for anyone else to see my cries for help. I've made some fixes that enable 2.5 compatibility ( It all looks fine to me, the error is insistent that it's not an object, but it is. I've tried getting around this in quite a few ways but it always boils back down to this. Oddly I can output the result of If you can quickly point me in the right direction I'm happy to put the PR together. Assuming it's not a bigger job than it seems. |
If you can show me the stack trace from the error, I can look at it. That function gets passed an element, and I need to see where that element comes from :) |
@designermonkey How do I instigate a stack trace myself? |
It should be listed under the error you've shown? |
Ah I see, nope, not in this case :( I just get exactly what's quoted in the original issue. |
Any page you're on in particular? Or just the login page? |
The error is shown after login, so when trying to display a page, i.e. the default section for the user. The section is one they're allowed to view as well, so it's not that. |
Do you have Order Entries installed? I had a similar problem on the login page once. |
Also, try dropping |
I certainly do. Although it'd be pretty hard to test as removing it would involve quite a bit of section editing. |
@designermonkey
Just inside the |
Try uncommenting the delegate functions in the extension driver. Am 21.08.2014 um 11:57 schrieb Nathan Hornby notifications@github.com:
|
Sorry I can't see any functions currently commented out - am I misunderstanding your instruction? |
Sorry, I meant the other way around: try to comment out the functions referenced by the delegates. |
Ah, I get a different error (with a stack trace!) if I set the default area to somewhere where there isn't an Order Entries field:
@nilshoerrmann I tried that just in case (on the Order Entires and this extension) and it didn't seem to have an impact. |
well, just pastie it and attach the link here, and I'll look a little later. Off out for lunch. |
@designermonkey It's bigger than the 64kb limit on Pastie :p It's a massive wall of stuff - unless you're looking for something in particular within it, I'm not sure the raw dump will be much help? |
@nathanhornby From what I see, you are dealing with a major case of recursion shit. Can you try:
private static function findChildren(XMLElement $element, $names) { and report back the new error.
if ($element == null) { return $children } The recursion loops looks weird to me as it does not have any exit checks. |
the second snippet is missing a ; (can't edit my posts, I am on a really old macbook stuck with Chrome 21) |
Thanks! I'll give this a try when I get the chance and report back.
|
@nitriques I've added that in (all makes sense), however unfortunately it hasn't had any effect.
For line |
Did you revert all other changes you made ? We should at least go further in the stack... |
Ah I see, well that was due to the presence of As noted I don't have order entries on this build. However I've just set a section up with it and hitting that section post-login with the author role is now giving me:
Highlighting line Important bit of the backtrace:
|
Great we are making progress. Thr non object is that string. Can you post the complete stack trace please ? Nicolas BrassardEnvoyé de mon iPhone: désolé si la qualité de mon français fait défaut.
|
You probably missed my edit, but here's the full backtrace anyway!
|
I do not know why a string would get stored as a "child" (@brendo, @designermonkey ?) but seems like that's what you have on your setup... Would you mind to try this implementation ? private static function findChildren($element, $names) {
if(!is_array($names)) {
$names = explode(',', $names);
}
$children = array();
if (!($element instanceof XMLElement)) {
return $children;
}
foreach($element->getChildren() as $child) {
$children = array_merge($children, self::findChildren($child,$names));
if(in_array($child->getName(), $names )) {
$children[] = $child;
}
}
return $children;
} |
Line
Content of line
|
Ah, interestingly the
|
I've forked this to Symphonists, and created an This is by no means exhaustive, and to be honest, it's a very involved task to get this extension up to date. It's done an admirable job of using the awful I've never used Author Roles for any project, so I'm far from an expert in this regard and will not be able to complete the update. |
Thanks Brendan. So would you say it could do with a rewrite? It's a very handy extension when you need it - Ive used it a couple of times for enabling user access to a 'blogging' area whilst keeping them away from the site data. It's a pretty elegant and powerful extension so it'd be a shame to see it get left behind.
|
There are new delegates available in the Author perspective in Symphony. I have a concept to flesh out from a planning perspective, but Nathan Hornby wrote:
|
The code should then be private static function findChildren($element, $names) {
if(!is_array($names)) {
$names = explode(',', $names);
}
$children = array();
if (!($element instanceof XMLElement)) {
return $children;
}
foreach($element->getChildren() as $child) {
$children = array_merge($children, self::findChildren($child,$names));
if($child instanceof XMLElement && in_array($child->getName(), $names )) {
$children[] = $child;
}
}
return $children;
} I've never used it either BTW. |
You cracked it @nitriques good job! Especially as you don't even use it :)
Depends what you mean by 'pseudo-hides' it, but it's not still in the
…
|
My pleasure, I really like recursions: they are so easy to code and so evil! |
Removes it from the DOM, but if you know the URL... You can still see the page. But, I haven't checked this for a long time. |
Ah, you may be right there, haven't tested that. In my implementations that isn't really an issue, but if it's for more sensitive use-cases that's an important point (if the case, I'll test at some point). @nitriques I can get your fix added into a commit in the new Symphonists fork (I'm assuming this will become the new maintained version?) - or did you want to get it added in yourself? I won't have a chance to do it until tomorrow either way. |
@nathanhornby please do it I do not even use this extension! As for the symphonist fork, I'll let @brendo answer. |
Provided by @nitriques
@designermonkey Just wanted to confirm that you're correct - although the extension removes the menu items it doesn't actively prevent the user from navigation to a section via the URL. I'm assuming this isn't a particularly tall order though? Does Symphony provide a way to easily trigger the 'Access Denied' message like you see when an 'Author' attempts to visit the preferences page? There'll be a delegate we can tie this to, I assume, along with an existing piece of logic already used to hide the sections. |
Administration::instance()->throwCustomError(
__('You are not authorised to access this page.'),
__('Access Denied'),
Page::HTTP_STATUS_UNAUTHORIZED
); |
Thanks @brendo ! I'll take a look at this myself later, see if I can't cobble something together. |
Has this extension been firmed up for use with 2.5 and 2.6? looking at the above it seems a fork over to Symphonists has the changes but I get getName() errors still. |
@andrewminton I do not used it for a while. Please send any PR to the symphonist repo tho. Thanks. |
Seems like a checkfor an object or not fixes it here too... needs more testing but will send PR to repo 'Symphonists' when done. |
Thanks Andrew. |
When attempting to login with a user account assigned a custom role I'm getting the following error:
I won't pretend to understand the issue, as after a quick check the item in question is, in fact, an object.
This is on Symphony 2.4.
The text was updated successfully, but these errors were encountered: