celfred Posted October 3, 2015 Share Posted October 3, 2015 Hello to the community, I'm facing a rather weird issue on my PW site with the pages2pdf module and urlSegments. Maybe one of you will help me figure this out. I have this code : // PDF Download link if (!$input->get['pages2pdf'] && $user->isSuperuser()) { echo '<a class="pdfLink btn btn-info" href="' . $page->url.$input->urlSegment1.'/'.$input->urlSegment2.'/'.$input->urlSegment3. '?sort='.$sort.'&pages2pdf=1">Get PDF</a>'; } My urlSegments are as follow : 1='all', 2='6bc', 3='12345'. In other words, I want to generate a PDF file listing 'all' events recorder for the team '6bc' during the time period id '12345'. It all works fine on my localhost site, but when I am online, I get an 'unknown selector' error instead of my PDF file. I have managed to find out that if I replace my urlSegment2 with an integer value, it works ! Why and how is this possible, I have absolutely no idea... I have other pages on my site where it all works fine with strings... I wonder, then, if I shoud go and replace all of my 'logic' : use query strings instead of urlSegments? Anyway, if anybody could give me a clue to solve this issue I would greatly appreciate Thanks in advance. Link to comment Share on other sites More sharing options...
LostKobrakai Posted October 3, 2015 Share Posted October 3, 2015 To be able to help we would rather need to see how you resolve those url segments instead of the raw concatenation of the url, which isn't the part that produces the error. Link to comment Share on other sites More sharing options...
celfred Posted October 3, 2015 Author Share Posted October 3, 2015 Actually, I thought as you say at first and struggled a couple of hours trying to isolate the code that triggers the error. I finally emptied my target page with just a : <?php echo 'test'; ?> But the error remained and it IS triggered by this call. As I mentionned in my first post, if I manually type '123' (or whatever number) in place of my urlSegment2, it works as expected. If I manually type '6bc' (or even 'bc') in my url, it throws the following error message : Error: Exception: Unknown Selector operator: '' -- was your selector value properly escaped? (in /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/Selectors.php line 247) #0 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/Selectors.php(284): Selectors->create('bc', '', '') #1 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/Selectors.php(81): Selectors->extractString('bc') #2 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/Pages.php(165): Selectors->__construct('bc') #3 [internal function]: Pages->___find('bc', Array) #4 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/Wire.php(389): call_user_func_array(Array, Array) #5 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/Wire.php(344): Wire->runHooks('find', Array) #6 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/Pages.php(260): Wire->__call('find', Array) #7 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/Pages.php(260): Pages->find('bc', Array) #8 /data/web This error message was shown because you are logged in as a Superuser. Error has been logged. While writing this message, I've just tried manually entering '123' in the adress bar of the navigator, and it works right away, echoing my 'test' line in my PDF file... If I type a string (any character), it throws the error... Link to comment Share on other sites More sharing options...
LostKobrakai Posted October 3, 2015 Share Posted October 3, 2015 Which version of processwire are you running? Also what are your urlSegments settings for that template? Link to comment Share on other sites More sharing options...
celfred Posted October 3, 2015 Author Share Posted October 3, 2015 PW 2.5.3 and I've just ticked the 'Allow URL Segments' box. Settings are the defaults, I guess. (and no pagination) As I mentionned earlier, it works on my localhost. Maybe that could help, but I have no idea what to do with that... What is really weird is that I have other pages that work perfectly (with strings). The only difference I can notice is that here, I'm using 3 urlSegments. By the way, thanks a lot for your help. Link to comment Share on other sites More sharing options...
LostKobrakai Posted October 3, 2015 Share Posted October 3, 2015 Does updating to the newest stable version (2.6.1) resolve the issue? If not would it be possible to get the full stack trace as the error is probably rooted far earlier in the stack then what the error message is showing. To get the full trace you'd need to add a line at the bottom of the index.php file. Maybe you also need to comment out the other lines, not sure as I haven't tested it. … } catch(Exception $e) { echo $e->getTraceAsString(); //Add this line /* * Formulate error message and send to the error handler * */ if($process) $process->failed($e); $errorMessage = "Exception: " . $e->getMessage() . " (in " . $e->getFile() . " line " . $e->getLine() . ")"; if($config->debug || ($wire && $wire->user && $wire->user->isSuperuser())) $errorMessage .= "\n\n" . $e->getTraceAsString(); trigger_error($errorMessage, E_USER_ERROR); } 3 Link to comment Share on other sites More sharing options...
celfred Posted October 3, 2015 Author Share Posted October 3, 2015 (edited) Here's where I am : - Updated to PW 2.6.1 -> The problem still happens. - I added the line you told me. Here's the result : #0 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/Selectors.php(318): Selectors->create('bc', '', '') #1 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/Selectors.php(115): Selectors->extractString('bc') #2 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/Selectors.php(104): Selectors->setSelectorString('bc') #3 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/Pages.php(203): Selectors->__construct('bc') #4 [internal function]: Pages->___find('bc', Array) #5 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/Wire.php(387): call_user_func_array(Array, Array) #6 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/Wire.php(325): Wire->runHooks('find', Array) #7 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/Pages.php(310): Wire->__call('find', Array) #8 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/Pages.php(310): Pages->find('bc', Array) #9 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/Pages.php(325): Pages->findOne('bc') #10 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/site/templates/pages2pdf/_footer.php(11): Pages->get('bc') #11 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/TemplateFile.php(169): require('/data/web/d9/a9...') #12 [internal function]: TemplateFile->___render() #13 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/Wire.php(387): call_user_func_array(Array, Array) #14 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/Wire.php(325): Wire->runHooks('render', Array) #15 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/site/modules/Pages2Pdf/WirePDF.module(244): Wire->__call('render', Array) #16 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/site/modules/Pages2Pdf/WirePDF.module(244): TemplateFile->render() #17 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/site/modules/Pages2Pdf/WirePDF.module(182): WirePDF->getMarkup('markupFooter') #18 [internal function]: WirePDF->___initPDF() #19 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/Wire.php(387): call_user_func_array(Array, Array) #20 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/Wire.php(325): Wire->runHooks('initPDF', Array) #21 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/site/modules/Pages2Pdf/WirePDF.module(143): Wire->__call('initPDF', Array) #22 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/site/modules/Pages2Pdf/WirePDF.module(143): WirePDF->initPDF() #23 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/site/modules/Pages2Pdf/Pages2Pdf.module(497): WirePDF->save('/data/web/d9/a9...') #24 [internal function]: Pages2Pdf->___createPDF(Object(Page), NULL) #25 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/Wire.php(387): call_user_func_array(Array, Array) #26 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/Wire.php(325): Wire->runHooks('createPDF', Array) #27 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/site/modules/Pages2Pdf/Pages2Pdf.module(317): Wire->__call('createPDF', Array) #28 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/site/modules/Pages2Pdf/Pages2Pdf.module(317): Pages2Pdf->createPDF(Object(Page), NULL) #29 [internal function]: Pages2Pdf->___download(Object(Page)) #30 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/Wire.php(387): call_user_func_array(Array, Array) #31 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/Wire.php(325): Wire->runHooks('download', Array) #32 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/site/modules/Pages2Pdf/Pages2Pdf.module(99): Wire->__call('download', Array) #33 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/site/modules/Pages2Pdf/Pages2Pdf.module(99): Pages2Pdf->download(Object(Page)) #34 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/Modules.php(464): Pages2Pdf->ready() #35 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/Modules.php(553): Modules->readyModule(Object(Pages2Pdf)) #36 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/ProcessWire.php(315): Modules->triggerReady() #37 [internal function]: ProcessWire->___ready() #38 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/Wire.php(387): call_user_func_array(Array, Array) #39 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/Wire.php(325): Wire->runHooks('ready', Array) #40 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/ProcessWire.php(347): Wire->__call('ready', Array) #41 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/ProcessWire.php(291): ProcessWire->__call('ready', Array) #42 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/ProcessWire.php(291): ProcessWire->ready() #43 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/modules/Process/ProcessPageView.module(227): ProcessWire->setStatus(4) #44 [internal function]: ProcessPageView->___ready() #45 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/Wire.php(387): call_user_func_array(Array, Array) #46 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/Wire.php(325): Wire->runHooks('ready', Array) #47 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/modules/Process/ProcessPageView.module(152): Wire->__call('ready', Array) #48 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/modules/Process/ProcessPageView.module(152): ProcessPageView->ready() #49 [internal function]: ProcessPageView->___execute(true) #50 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/Wire.php(387): call_user_func_array(Array, Array) #51 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/Wire.php(325): Wire->runHooks('execute', Array) #52 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/index.php(241): Wire->__call('execute', Array) #53 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/index.php(241): ProcessPageView->execute(true) #54 {main} Error: Exception: Unknown Selector operator: '' -- was your selector value properly escaped? (in /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/Selectors.php line 281) #0 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/Selectors.php(318): Selectors->create('bc', '', '') #1 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/Selectors.php(115): Selectors->extractString('bc') #2 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/Selectors.php(104): Selectors->setSelectorString('bc') #3 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/Pages.php(203): Selectors->__construct('bc') #4 [internal function]: Pages->___find('bc', Array) #5 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/Wire.php(387): call_user_func_array(Array, Array) #6 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/Wire.php(325): Wire->runHooks('find', Array) #7 /data/web/d9/a9/72/planetalert.tuxfamily.org/htdocs/wire/core/Pages.php(310): Wire->__call('find', Arra This error message was shown because you are logged in as a Superuser. Error has been logged. And here's my very limited analysis and what I managed to do and understand : - #10 is trying to get the page from my urlSegment2 string. I've noticed the call to the _footer page and remembered having the 'Print footer' option enabled in my pages2pdf module. I unchecked the option and.... tada! It works! My _footer.php page contains : <?php echo 'page générée le '.date("d/m/y \à h:i:s"); ?> So I figured out that maybe the problem would be in the pages2pdf module : shouldn't it call the Pages->get('name=urlSegment2') instead of Pages->get('urlSegment2')? Actually I may be totally wrong on that since much of this is way over my head, but I'm trying (hard, I promise ) to understand why this happened. Anyway, THANKS for your help since I can now make it work (loosing my footer is no big deal). An afterthought : I wondered why it worked on my localhost... I was using pages2pdf 1.1.1 (and 1.1.5 on the remote). Maybe an explanation? Edited October 3, 2015 by celfred Link to comment Share on other sites More sharing options...
LostKobrakai Posted October 3, 2015 Share Posted October 3, 2015 You said your urlSegment2 was '6bc', but somehow pages2pdf is searching for just 'bc'. But the version change could also be the culpit. 1 Link to comment Share on other sites More sharing options...
celfred Posted October 3, 2015 Author Share Posted October 3, 2015 Oh yes! The '6bc' 'bc' change is due to my numerous tests. I manually wrote 'bc' to avoid a number (another 'idea' of mine). It works fine now with '6bc' passed through the urlSegment2 value. I'll test further on with the footer option in pages2pdf and mention it to the module's creator if I see an issue there. Thanks a lot for your help. 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