I added the following condition as php code:
<? $_GET["theme"]=="garland";?>
and now I get this message and it stays in the virtual site, doesnt go back to the original site.

Notice: Undefined index: operator in virtual_site_condition_php() (line 104 of C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\pn\sites\all\modules\virtual_site\condition\virtual_site_condition.basic.inc).

Comments

reswild’s picture

Don't you need to actually return a value here? Like:

if ($_GET["theme"]=="garland") {
  return TRUE;
}

Another thing is that PHP conditions are still broken in the stable release for D7. I can see that it has been fixed in the dev version for some time, but it would be good to roll out a new version for this, as this is something that is likely to take down your whole site.

lemagus’s picture

Issue summary: View changes

I had the same problem I think it's because of PHP 5.4
Anyways here something that worked for me :

Replace :

return ($context['operator'] == CONDITION_SKIP || !$context['code'] || (module_exists('php') && php_eval($context['code'])));

Line 104 in /sites/all/modules/virtual_site/condition/virtual_site_condition.basic.inc with :

return ( (!empty($context['operator']) && $context['operator'] == CONDITION_SKIP) || !$context['code'] || (module_exists('php') && php_eval($context['code'])));

Cheers

AdamPS’s picture

It looks to me as if the problem is that the PHP form doesn't have the operator section on it. However the code that evaluates the condition assumes the operator is set.

So the fix is to virtual_site_condition_php_form, add
$form['pages_operator'] = array(
etc.

I'll try and get a fix posted for this some time.

AdamPS’s picture

Assigned: Unassigned » AdamPS

  • AdamPS committed 98ae025 on 7.x-1.x
    Issue #1935460: php  code as condition not working
    
AdamPS’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.