English > Install & Configure jDiction

Searching with finder

<< < (7/7)

Finarfin:
Totalitems is not correctly calculated. You calculate totalitems before with the new getTotalCount.

I mean, getItems select 20 rows but return 40 items because of jdiction. Then, you increase the offset by 20 (ok), but reduce the totalItems by 20 (false, you´ll to do here totalitems -= count(items)

I´m going to keep yet the offset/count(languages) inside getItems. YOu know, is magic, dont touch it :D



In another topic, I don´t want to think too much if there would be problems if you have enough articles with languages differents than '*' :P

Harald Leithner:
You are right, this should be better:


--- Code: --- // Iterate through the items and index them.
    for ($i = 0, $n = count($items); $i < $n; $i++)
    {
      // Index the item.
      $this->index($items[$i]);

      $iState->totalItems--;
    }

    // Adjust the offsets.
    if ($limit > count($items)) {
      $limit = count($items);
    }
    $offset += $limit;
    $iState->batchOffset += $limit;
--- End code ---

Finarfin:
Well, I could clean the code so I´ll try to compilate:



* Bug, unresolved: Triying to execute the indexer from console will fail to load Jdiction, so it won´t translate properly the entries.
* jdcontent.php
* Line 287,

$params = $obj->params;

will generate notice or warnings, I have added a check here

if (isset($obj)) { $params = $obj->params }

* Line 366, there are two problematic lines

if (strpos($item->route, 'Itemid'))

but as long as I could recall, this comparison leave out a lot of entries. And this comparisons aren´t on the original content.php. I have changed them Itemid with id, but I guess that even this comparison is meaningless and unnecesary

* Line 450, function getListQuery

I have added this line before returning the query

$sql->order("a.id");

I don´t know why, but when I was doing the queries it returns me something like

id 21
id 22
id 23
id 18, this one entry is out of order, something that really doesn´t have to affect the results, but it seemed to do...

* adapter.php
* I´m going to keep my adapter version. I have being tracing my solution and is not efficient (it will reindex several times the same item), but it gets the job done. I have tried your onBuildIndex but doesn´t work, I think that is because of the way it calculates the limit. I would like to do more test and let you know but I´m near production and this is currently working :D:D

* Line 90, getItems function,

$db = JFactory::getDbo()

or

use $this->db
?

* Line 113, the solution I´m using

setQuery($query, $offset/count($languages), $limit)

instead of
setQuery($query, $offset, $limit)

the other posibility would be override onBuildIndex, but I don´t have the time to do the proper tests and this is working now :P

* Add the getContentCount function we said before

* jddatabase.php
* method_exists(parent, )
is wrong, the proper method to avoid notices is
method_exists(get_parent_class($this), )

There is at least two of this method_exists(parent). I could solve one, but the other one seems to break with the change.

* Unresolved bug, probably nothing related to jdiction: When the indexer tries to optimize a big table like the one generated, it breaks.

Harald Leithner:

--- Quote from: Finarfin on July 13, 2013, 09:32:45 pm ---Well, I could clean the code so I´ll try to compilate:



* Bug, unresolved: Triying to execute the indexer from console will fail to load Jdiction, so it won´t translate properly the entries.
--- End quote ---
Didn't check this sorry

--- Quote from: Finarfin on July 13, 2013, 09:32:45 pm ---
* jdcontent.php
* Line 287,

$params = $obj->params;

will generate notice or warnings, I have added a check here

if (isset($obj)) { $params = $obj->params }

--- End quote ---
Fixed

--- Quote from: Finarfin on July 13, 2013, 09:32:45 pm ---
* Line 366, there are two problematic lines

if (strpos($item->route, 'Itemid'))

but as long as I could recall, this comparison leave out a lot of entries. And this comparisons aren´t on the original content.php. I have changed them Itemid with id, but I guess that even this comparison is meaningless and unnecesary

--- End quote ---
Fixed by removing this code, I filtered all articles out where no menu item and no category menu item exists, (used by me for special pages, but this is better done with meta data robots: "noindex" option

--- Quote from: Finarfin on July 13, 2013, 09:32:45 pm ---
* Line 450, function getListQuery

I have added this line before returning the query

$sql->order("a.id");

I don´t know why, but when I was doing the queries it returns me something like

id 21
id 22
id 23
id 18, this one entry is out of order, something that really doesn´t have to affect the results, but it seemed to do...

--- End quote ---
thats hard to say why this is, maybe you print the query that get fired and try them in phpmyadmin

--- Quote from: Finarfin on July 13, 2013, 09:32:45 pm ---[li]adapter.php[/li]

* I´m going to keep my adapter version. I have being tracing my solution and is not efficient (it will reindex several times the same item), but it gets the job done. I have tried your onBuildIndex but doesn´t work, I think that is because of the way it calculates the limit. I would like to do more test and let you know but I´m near production and this is currently working :D:D

--- End quote ---
I followed your approach until I have time to fix it

--- Quote from: Finarfin on July 13, 2013, 09:32:45 pm ---
* Line 90, getItems function,

$db = JFactory::getDbo()

or

use $this->db
?

--- End quote ---
Changed

--- Quote from: Finarfin on July 13, 2013, 09:32:45 pm ---
* Line 113, the solution I´m using

setQuery($query, $offset/count($languages), $limit)

instead of
setQuery($query, $offset, $limit)

the other posibility would be override onBuildIndex, but I don´t have the time to do the proper tests and this is working now :P

--- End quote ---
As mentioned above I use the same code until I fix it.

--- Quote from: Finarfin on July 13, 2013, 09:32:45 pm ---
* Add the getContentCount function we said before

--- End quote ---
done ;-)

--- Quote from: Finarfin on July 13, 2013, 09:32:45 pm ---[li]jddatabase.php[/li]

* method_exists(parent, )
is wrong, the proper method to avoid notices is
method_exists(get_parent_class($this), )

There is at least two of this method_exists(parent). I could solve one, but the other one seems to break with the change.
[/list]

--- End quote ---
I removed both calls to parent::__wakeup and parent::__sleep because they are not used in joomla atm.

--- Quote from: Finarfin on July 13, 2013, 09:32:45 pm ---
* Unresolved bug, probably nothing related to jdiction: When the indexer tries to optimize a big table like the one generated, it breaks.

--- End quote ---
Did'nt tested this.


I attached the 3 files I changed so they should work with your version. I also updated some variables from joomla-master.

Navigation

[0] Message Index

[*] Previous page

Go to full version