Jump to content

Exception: Unknown Selector operator: '' -- was your selector value properly escaped? (in ...../public_html/wire/core/Selectors.php line 247


MuchDev
 Share

Recommended Posts

Alright this bug has me a bit stumped, as it happens intermittently only on one template on my site usually during high traffic times. The pages all render perfectly of course when I go to check to make sure that the site itself hasn't crashed, but otherwise I just keep getting this message off various pages that use this template (around 8000 pages). So from what I have seen referencing this error has all been in regards to a $pages->find call that has a leading space in a selector.  So the problem is that this page uses no finds directly yet I am still getting the error. Which other methods would cause this exception?

I was going to post the code, but this is a pretty large template and I dont want to totally overload everyone with the main display of all artwork lists. 

I feel like this may be related to high traffic times and procache flushing the cache on pages that users are trying to load simultaneously... Any geniuses feel like throwin' your gloves in the ring? :)

Link to comment
Share on other sites

Despite the annoyance of a lot of code - your best bet at getting a solid answer should be to post it since the error indicates some form of special character or otherwise malformed selector... Happy to take a look though.

  • Like 1
Link to comment
Share on other sites

Well don't say I didn't warn you. Here is a collapsed version so that you can see most of the ins and outs :).

<?php
include('./includes/header.inc');
include('./includes/itemFunctions.inc');
include('./includes/socialButtons.inc');
include ("./includes/contactForm.inc");

echo generateLightbox();
echo generateArtBio();

//if artist is contemporary use phrase "featured works"
//if artist is antique use phrase "available works"
$verbage = "";

## testing fix 2-2-2015
## removed extra leading space in id selector for unknown selector bug
if($page->parent->id==1248){
	$verbage = "Featured works by: ";
}elseif($page->parent->id==3636||$page->id==3637){
	$verbage = "Available works by: ";
}

//set max items
if ($page->maxItems){
	$maxItems = $page->maxItems;
}else{
	$maxItems = 50;
}

##################################

$parents = $page->children;
$items = new PageArray();
$allitems = new PageArray();

foreach($parents as $thisItem){
	$items->import($thisItem);	
	$items->import($thisItem->children);
	$allitems->import($thisItem);	
	$allitems->import($thisItem->children);	
}

// configuration for pagination needed
$total = $items->count();
$start = ($input->pageNum-1)*$maxItems;

$items->setLimit($maxItems);
$items->setTotal($total);
$items->setStart($start);

##################################

$born = $page->artist_born;
$died = $page->artist_died;
$nationality = $page->artist_nationality;

if($born || $died){
	if($died == "") $died = "    ";
	$birthDeath = '<small>('.$born.' - '.$died.')</small>';
}

?>

<section class="container wrap">
	<div class="row">
		<div class="artist-intro">
			<h2 class="sectionTitle"><?php echo $verbage;?><strong><?php echo $page->artist_firstname.' '.$page->artist_lastname.'  '.$birthDeath;?></strong>   <? echo $nationality; ?></h2>
				<div class="artbioTop">
					<?php 

					echo $page->artist_biography_snippet;
					
					if($page->artist_biography!=""||strlen($page->artist_biography)>10)//if there is a bio then print markup for button else just render social buttons
					{
						$bioBtn = "";
						$bioBtn .= '<div class="bioBtnHolder">';	
						$bioBtn .= '<div class="bioBtnHolder">';	
						$bioBtn .= '<button href="#artBio" class="artistBio btn btn-default" data-toggle="modal"><span class="artBioIcon glyphicon glyphicon-user"></span>Artist Biography</button>';	
						$bioBtn .= '</div>';	
						if($page->YouTube) $bioBtn .= youTubeButtons($page);							
						$bioBtn	.= renderDownloads($page);						
						$bioBtn .= renderSocial();
						$bioBtn .= '</div>';	
						$bioBtn .= '</div>';	
						echo $bioBtn;
					}else{
						$bioBtn = "";
						$bioBtn .= '<div class="bioBtnHolder">';	
						if($page->YouTube) $bioBtn .= youTubeButtons($page);
						$bioBtn	.= renderDownloads($page);					
						$bioBtn .= renderSocial();
						$bioBtn .= '</div>';	
						$bioBtn .= '</div>';	
						echo $bioBtn;						
					}						
					
					?>
		</div>
	</div>
	<div class="row">

<?php 	
	
	//social dropdown and pagination menu
	
	$hasSections = false;
	
	foreach($parents as $child){
		if($child->template=="itemsSection"){
			$hasSections = true;
		}
	}
	
	if($hasSections||$items->getTotal()>=$maxItems){
		echo '<div class="pageNavTop">';
		echo '<div class="socialHolder socialHeader">';
		if($page->useButtons==1)echo generateButtons($allitems);
		
		echo '</div>';
		echo $items->renderPager(array(
			'listMarkup' => "<ul class='pagination pageNavBtns'>{out}</ul>",
			'currentItemClass' => "active"));
		echo "</div>";

	}else{
		echo "<div class='spacer'></div>";
	}
	?>
		</div>
	</div>
	<?php
		if(count($items)<1){
		
			$dflt .= '<div class="row">';
			$dflt .= '<div class="col-xs-12"> ';
			$dflt .= '<img class="fitwidth align-center" src="'.$pages->get(4945)->UnderDevelopment->first()->url.'">';
			$dflt .= '</div>';
			$dflt .= '</div>';
			echo $dflt;
		}
	?>
	<div id="masonry" class="row">	

<?php 
foreach($items->filter("limit={$maxItems},start={$start}") as $item){

//Remember to not return any tags in the string if no information has been returned. 
	//option 1 - one is an item and then just print it.
	if($item->template->name=='items'){
		$gridSizer = $item->gridSizer;
		echo generateItem($item,$gridSizer);
	}
	//option 2 is a subsection. Print 100%width divider with text areas
	if($item->template->name=='itemsSection'){
		echo "<div id=".$item->id." class='grid-item masonrySection col-xs-12 subsection'>";
		if ($item->subsection_description){
				echo "<h2>{$item->title}</h2>";				
				echo "<p>{$item->subsection_description}</p>";
			}else{
				echo "<h2>{$item->title}</h2>";				
			}
		echo generateButtons($allitems);
		echo "</div>";
	}
}
?>
	<div class="cards sizer col-lg-3 col-md-4 col-sm-6 col-xs-12"></div><!--setup widths-->
	</div>
	<hr/>
	<?php echo generatePager($items); ?>

</section><!--end page-wrapper-->

<?php include ("./includes/footnav.inc");?>
<?php include ("./includes/footer.inc");?>

Link to comment
Share on other sites

Without looking at your code and just digging through the source it seems the error is thrown for an operator (i.e. the = or *= etc) being unrecognised. Since the function throwing the exception also has a nice debug entry it might help to run the template in debug mode and see what comes out of it.

Quick glance over the code above does not flag up any major issues as far as I can see, but I'll take another look once I've drowned my brain in coffee.

  • Like 1
Link to comment
Share on other sites

I guess it has to be this line as it's the only selector I see so far in your code:

$items->filter("limit={$maxItems},start={$start}"

Aye.

MuchDev, are there selectors used in any of the included files. Especially ./includes/itemFunctions.inc raises my suspicions here if there is a function defined that is only used by this page. There are a few functions that appear custom ones, so that would be my next check.

  • Like 1
Link to comment
Share on other sites

Well I really appreciate the extra sets of eyeballs :) I have stretched the cache time out using procache and I haven't seen an issue in the past several days or so which is further convincing me that this is related to the amount of load on the site at the time that the page is attempting to be regenerated. That selector is just unable to pull any items because the site is busy maybe? 

Aye.

MuchDev, are there selectors used in any of the included files. Especially ./includes/itemFunctions.inc raises my suspicions here if there is a function defined that is only used by this page. There are a few functions that appear custom ones, so that would be my next check.

itemFunctions is all markup related and generates the item cards based on the page fields supplied to it via functions, so there is no selectors. Also all of the custom functions included in this template are called in two other templates that do not generate this error.

@MuchDev: Could you turn your debug mode on (go to config.php and set $config->debug to true) and then post the whole error message?

I would but as this is a live site now wouldn't debug mode cause all users to view current debug information?

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...