summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernhard Posselt <Raydiation@users.noreply.github.com>2013-09-05 03:27:11 -0700
committerBernhard Posselt <Raydiation@users.noreply.github.com>2013-09-05 03:27:11 -0700
commit88e0ab3e1f41a4058015b4b9b44d914a3c2c634c (patch)
tree9b0c7d9d32bbd1b24985900a56faa3d45f74cfc0
parente3dc31a5ae79f70d92a0dbc521095093ed6a4011 (diff)
parent772999e5628e62286c95f7e11635585404660a88 (diff)
Merge pull request #334 from bastei/master
2 Fixes: deleteReadOlderThanThreshold calculation fix and multiple XPath results for articleenhancer
-rw-r--r--db/itemmapper.php2
-rw-r--r--tests/unit/db/ItemMapperTest.php4
-rw-r--r--tests/unit/utility/articleenhancer/ArticleEnhancerTest.php10
-rw-r--r--utility/articleenhancer/articleenhancer.php8
4 files changed, 12 insertions, 12 deletions
diff --git a/db/itemmapper.php b/db/itemmapper.php
index 1dd9726e4..e66b8c166 100644
--- a/db/itemmapper.php
+++ b/db/itemmapper.php
@@ -259,7 +259,7 @@ class ItemMapper extends Mapper implements IMapper {
while($row = $result->fetchRow()) {
- $limit = $threshold - $row['size'];
+ $limit = $row['size'] - $threshold;
if($limit > 0) {
$params = array($status, $row['feed_id']);
diff --git a/tests/unit/db/ItemMapperTest.php b/tests/unit/db/ItemMapperTest.php
index de6edeba6..fe1de517a 100644
--- a/tests/unit/db/ItemMapperTest.php
+++ b/tests/unit/db/ItemMapperTest.php
@@ -320,7 +320,7 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
'HAVING COUNT(*) > ?';
$threshold = 10;
- $rows = array(array('feed_id' => 30, 'size' => 11));
+ $rows = array(array('feed_id' => 30, 'size' => 9));
$params = array($status, $threshold);
$this->setMapperResult($sql, $params, $rows);
@@ -340,7 +340,7 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
$params1 = array($status, $threshold);
- $row = array('feed_id' => 30, 'size' => 9);
+ $row = array('feed_id' => 30, 'size' => 11);
$sql2 = 'DELETE FROM `*PREFIX*news_items` `items` ' .
'WHERE NOT ((`status` & ?) > 0) ' .
diff --git a/tests/unit/utility/articleenhancer/ArticleEnhancerTest.php b/tests/unit/utility/articleenhancer/ArticleEnhancerTest.php
index 5f82a4752..a59bf9485 100644
--- a/tests/unit/utility/articleenhancer/ArticleEnhancerTest.php
+++ b/tests/unit/utility/articleenhancer/ArticleEnhancerTest.php
@@ -58,7 +58,7 @@ class ArticleEnhancerTest extends \OCA\AppFramework\Utility\TestUtility {
$this->fileFactory,
array(
'/explosm.net\/comics/' => '//*[@id=\'maincontent\']/div[2]/div/img',
- '/explosm.net\/shorts/' => '//*[@id=\'maincontent\']/div[2]/div'
+ '/explosm.net\/shorts/' => '//*[@id=\'maincontent\']/div/div'
),
$this->timeout
);
@@ -106,7 +106,7 @@ class ArticleEnhancerTest extends \OCA\AppFramework\Utility\TestUtility {
$file->body = '<html>
<body>
<div id="maincontent">
- <div>nooo</div>
+ <div>nooo<div>hiho</div></div>
<div><div>rawr</div></div>
</div>
</body>
@@ -122,11 +122,11 @@ class ArticleEnhancerTest extends \OCA\AppFramework\Utility\TestUtility {
->will($this->returnValue($file));
$this->purifier->expects($this->once())
->method('purify')
- ->with($this->equalTo('<div>rawr</div>'))
- ->will($this->returnValue('<div>rawr</div>'));
+ ->with($this->equalTo('<div>hiho</div><div>rawr</div>'))
+ ->will($this->returnValue('<div>hiho</div><div>rawr</div>'));
$result = $this->testEnhancer->enhance($item);
- $this->assertEquals('<div>rawr</div>', $result->getBody());
+ $this->assertEquals('<div>hiho</div><div>rawr</div>', $result->getBody());
}
diff --git a/utility/articleenhancer/articleenhancer.php b/utility/articleenhancer/articleenhancer.php
index 7565070f8..76bb0fa9f 100644
--- a/utility/articleenhancer/articleenhancer.php
+++ b/utility/articleenhancer/articleenhancer.php
@@ -88,11 +88,11 @@ abstract class ArticleEnhancer {
* @return the result as a string
*/
protected function domToString($xpathResult) {
- if($xpathResult->length > 0) {
- return $this->toInnerHTML($xpathResult->item(0));
- } else {
- return "";
+ $result = "";
+ foreach($xpathResult as $node) {
+ $result .= $this->toInnerHTML($node);
}
+ return $result;
}