After setting up a new server and updating everything to the latest, looking in my debug logs I keep finding this

Notice: Undefined index: ts_vid_2_names in Apache_Solr_Document->__get() (line 317 of /var/www/sites/all/modules/apachesolr/SolrPhpClient/Apache/Solr/Document.php).

Oh I forgot this happens when cron.php is run..

the code is


	/**
	 * Magic get for field values
	 *
	 * @param string $key
	 * @return mixed
	 */
	public function __get($key)
	{
		return $this->_fields[$key];
	}

this I believe is the revision 22..

Comments

nick_vh’s picture

Status: Active » Postponed (maintainer needs more info)

Could you please write a writeup on how to replicate this starting from an empty drupal?
I'd suppose you have 2 vocabularies and somehow your vocabulary with vid 2 is not indexing which could explain your error.

We'd have to know how it was possible that you have 2 vocabularies or more and that 1 of them is not indexed before we can try to solve it

gateway69’s picture

I ran though ubuntu project mercury install process, that sets up a nice lamp pressflow/varnish/apc/solr (version 1.4.1) then I moved one of our existing sites over

We have 5 vocabs listed.. with various terms, one think to note is we do use taxonomy menu as well, not sure if thats related.

If you can tell me where I could put some debug statements in I can help provide some feedback, but the install process is long and moving over a site took a while and it would be hard to prob do from scratch .. but i would like to help debug the issue.

nick_vh’s picture

You could try to debug the apachesolr.index.php file

function apachesolr_add_taxonomy_to_document($document, $node) {

Try to see which vocabularies are added? Once you have this list you can at least be sure what is being indexed.
Also if you go to the apachesolr admin (http://localhost:8983/solr/core0/admin/schema.jsp) you can see what dynamic fields you have available.

Keep us updated

kevin.dutra’s picture

Status: Postponed (maintainer needs more info) » Active

We get these same errors, although we're using 6.x-1.5. You'll see these popping up in server logs if you have PHP configured to report E_NOTICE level errors, or if you're using Drush to do indexing and you have the verbose mode enabled.

The culprit is the line that adds the field to the document (that's line 186 of apachesolr.index.inc in 6.x-1.5):

function apachesolr_add_taxonomy_to_document($document, $node) {
  ...
        $document->{'ts_vid_'. $ancestor->vid .'_names'} .= ' '. $name;
  ...
}

Since the ".=" operator is being used, the current value is implicitly looked up prior to appending $name, hence the call to __get() in Document.php. The first time a particular vid is encountered, this will cause the error to be generated since it doesn't yet exist in the array of fields. You'd get one of these for each vid in a document, so if you have a reasonably expansive taxonomy set and/or a large number of nodes being indexed, you can get inundated with these errors.

This could be fixed by checking whether the field has been set prior to trying to append. Something along the lines of:

  $ts_vid = 'ts_vid_'. $ancestor->vid .'_names';
  $document->{$ts_vid} = isset($document->{$ts_vid}) ? $document->{$ts_vid} . ' ' . $name : $name;
nick_vh’s picture

Status: Active » Needs work

Could you provide a patch for this?

kevin.dutra’s picture

StatusFileSize
new888 bytes

Sure, here it is. This is against 6.x-1.x-dev

lazysoundsystem’s picture

Thanks for the patch, Kevin, I can confirm it quietens the errors on 6.x-1.5.

lazysoundsystem’s picture

StatusFileSize
new880 bytes

Adding here exactly the same patch, but rolled with 'git diff --no-prefix' for use with drush_make.

nick_vh’s picture

Status: Needs work » Fixed

Looking good. Seems enough people reviewed the patch so committed it.

nick_vh’s picture

Version: 6.x-2.x-dev » 6.x-1.x-dev
gateway69’s picture

works for me!

Status: Fixed » Closed (fixed)

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

dergachev’s picture

Version: 6.x-1.x-dev » 6.x-2.x-dev
Status: Closed (fixed) » Needs review

Although the patch in #8 applies cleanly against 6.x-2.x, I re-rolled it anyways.
Tested it, so please consider committing to apachesolr 2.x.

dergachev’s picture

And with the patch, this time.

Also FYI this has been fixed in later versions of SolrPhpClient, see https://code.google.com/p/solr-php-client/source/browse/trunk/Apache/Sol...

Status: Needs review » Needs work

The last submitted patch, fix-php53-undefined-index-warning-1309252-14-6x2x.patch, failed testing.

dergachev’s picture

From the test log in #15:

PHP Fatal error:  Call to undefined function apachesolr_get_solr() in /var/lib/drupaltestbot/sites/default/files/checkout/sites/default/modules/apachesolr/tests/solr_index_and_search.test on line 23

Does this imply that the tests in 6.x-2.x are not working? I have a hard time believing my patch could cause this.

dergachev’s picture

Issue summary: View changes

added some more details