Modified module for Drupal 7 error

Notice: Trying to get the property of non-object in the context_geoip_condition-> execute () function (line 50 in the /var/www/mailfox/sites/all/modules/context_geoip/context_geoip_condition.inc file)

code from line 45

function execute() { if ($this->condition_used()) { $record = geoip_city(); foreach ($this->get_contexts() as $context) { $city_names = $this->fetch_from_context($context, 'values'); if (in_array($record->city, $city_names)) { $this->condition_met($context); } } } } } 

Download the module itself

    1 answer 1

    $ record is not an object. Most likely, geoip_city () returns false, because for some reason it did not cope with the task (for example, it sees ip 127.0.0.1), and for this it is necessary to provide a case when geoip_city () failed (add check to false).

    • the fact is that this module works fine on drupal 6 - mailfox
    • @mailfox, ok, how does that change things? - etki
    • So I want to figure it out myself ... in principle, everything should work as Hood @Fike. How do you propose to implement the check? - mailfox
    • pc if ($ record === false) return false; - etki
    • @Fike and what will it give me how can I find out where to catch the cause of the error in which logs to watch - mailfox