valan Posted August 15, 2015 Share Posted August 15, 2015 I'm doing my first steps as module developer and need some help. Here is my module https://github.com/valieand/GoogleCidCatcher This module adds hook after login which saves Google Customer ID from browser cookie to user page field 'user_google_cids'. It seem to work. But when I try to do the following somewhere in another place: $module = wire()->modules->get('GoogleCidCatcher'); I get Error: Exception: Unknown Selector operator: '' -- was your selector value properly escaped? (in /var/www/pw/wire/core/Selectors.php line 283) What is the reason and how to fix it? P.S. I can't enable debug mode as its a live site. Btw may be there exist another way to debug this error, less painful for live sites? Thanks. Link to comment Share on other sites More sharing options...
kongondo Posted August 15, 2015 Share Posted August 15, 2015 (edited) But when I try to do the following somewhere in another place: $module = wire()->modules->get('GoogleCidCatcher');I get Error: Exception: Unknown Selector operator: '' -- was your selector value properly escaped? (in /var/www/pw/wire/core/Selectors.php line 283)What is the reason and how to fix it? That syntax doesn't look right to me. If in a template file, you can call your module like this: $gCatcher = $modules->get("GoogleCidCatcher"); If in a function in a template file: $gCatcher = wire('modules')->get('GoogleCidCatcher'); If in a module you could use: $gCatcher = $this->modules->get('GoogleCidCatcher'); P.S. I can't enable debug mode as its a live site. Btw may be there exist another way to debug this error, less painful for live sites? Thanks. I can't find it now, but there is a way you can load a custom /site/config.php/ e.g. when logged as a superuser, load /site/dev.config.php. Any reason why you can't debug your module locally? Edited August 16, 2015 by kongondo Link to comment Share on other sites More sharing options...
valan Posted August 16, 2015 Author Share Posted August 16, 2015 @kongondo: - syntax is ok. I use it almost everywhere and it works w/o problems. E.g. wire()->pages, etc. Problem should be somewhere else. Could it be connected with autoload/singular module settings? Or use of __constructor()? I can't understand... - thanks for idea with custom config file for loggedin superuser. Is there any module for that? I'll experiment with it. I guess its a matter of setting $config->debug = true on each request, immediately after $config is initialized. But don't know which hook to use so far... - I don't use local/dev instance - its too time-consuming to keep things aligned/consistent in two systems. Link to comment Share on other sites More sharing options...
kongondo Posted August 16, 2015 Share Posted August 16, 2015 It's hard to debug without seeing the whole context. But the error message is clear, there's a problem somewhere with some selector. Problem is without debug on, you cannot really tell which line in what file is causing the error. What does your error.txt file say? Link to comment Share on other sites More sharing options...
valan Posted August 16, 2015 Author Share Posted August 16, 2015 error.txt file says the same. So far I've commented this piece of code till I find way to enable debug for superuser only. Link to comment Share on other sites More sharing options...
kongondo Posted August 16, 2015 Share Posted August 16, 2015 (edited) Here you go....read this (whole) topic very carefully: Enable debug mode for only superusers or a given username $config->debugIf might also be of interest.. Edited August 16, 2015 by kongondo 2 Link to comment Share on other sites More sharing options...
valan Posted August 16, 2015 Author Share Posted August 16, 2015 Thank you! Will check and come back later with source of the issue - if not site-specific, it could be useful for other module devs. Link to comment Share on other sites More sharing options...
Wanze Posted August 16, 2015 Share Posted August 16, 2015 @valan Looking through your code, I think that the problem could be this line: https://github.com/valieand/GoogleCidCatcher/blob/master/GoogleCidCatcher.module#L195 If your array is empty, you get a strange selector string. Also you are using array_filter without actually filtering anything in the array, not sure how PHP behaves. Normally you'd need to pass a closure as second argument, see: http://php.net/manual/en/function.array-filter.php Edit: Ok just read the docs, if you omit the closure as second argument when using array_filter, all FALSE entries are removed. 1 Link to comment Share on other sites More sharing options...
valan Posted August 25, 2015 Author Share Posted August 25, 2015 The problem was in https://github.com/valieand/GoogleCidCatcher/blob/master/GoogleCidCatcher.module#L38 I've commented this 'permission' => array() line and module start to work!) 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now