jDiction Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

jDiction 2.2.0 released. http://jdiction.org/downloads

Pages: 1 2 [3]

Author Topic: Searching with finder  (Read 55182 times)

Finarfin

  • Full Member
  • ***
  • Posts: 119
    • View Profile
Re: Searching with finder
« Reply #30 on: July 13, 2013, 03:18:04 pm »

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
Logged

Harald Leithner

  • Administrator
  • Hero Member
  • *****
  • Posts: 1688
    • View Profile
Re: Searching with finder
« Reply #31 on: July 13, 2013, 05:41:17 pm »

You are right, this should be better:

Code: [Select]
// 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;
Logged
Joomla! 5.0 Release Manager
Vote at JED

Finarfin

  • Full Member
  • ***
  • Posts: 119
    • View Profile
Re: Searching with finder
« Reply #32 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.
  • 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.

Logged

Harald Leithner

  • Administrator
  • Hero Member
  • *****
  • Posts: 1688
    • View Profile
Re: Searching with finder
« Reply #33 on: July 14, 2013, 12:57:30 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.
Didn't check this sorry
  • jdcontent.php
    • Line 287,

      $params = $obj->params;

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

      if (isset($obj)) { $params = $obj->params }
Fixed
  • 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
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
  • 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...
thats hard to say why this is, maybe you print the query that get fired and try them in phpmyadmin
    [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
    I followed your approach until I have time to fix it
    • Line 90, getItems function,

      $db = JFactory::getDbo()

      or

      use $this->db
      ?
    Changed
    • 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
    As mentioned above I use the same code until I fix it.
    • Add the getContentCount function we said before
    done ;-)
      [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]
      I removed both calls to parent::__wakeup and parent::__sleep because they are not used in joomla atm.
      • Unresolved bug, probably nothing related to jdiction: When the indexer tries to optimize a big table like the one generated, it breaks.
      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.
      Logged
      Joomla! 5.0 Release Manager
      Vote at JED

      Pages: 1 2 [3]