1
Hi there
In WFSection i think there is a bug, or some missing code.
In the getArticle method in wfsarticle.php something is weird:
function getArticle($articleid){
$sql = "SELECT * FROM ".$this->table." WHERE articleid=".$articleid." ";
$array = $this->db->fetchArray($this->db->query($sql));
if (count($array) == 0) {
return false;
}
$this->makeArticle($array);
}
If the count($array) is 0 false is returned, but the calling method does not use the returned value, and if the count is not 0 nothing is returned.
I guess the method should return false if the article was not found and true if it was found, so you could display an error message if people are trying to enter the articleid by hand.
count($array) returns false if nothing is returned from database, so it is never equal to 0.
I used this getArticle to detect wether an article is in the base or not:
function getArticle($articleid){
$sql = "SELECT * FROM ".$this->table." WHERE articleid=".$articleid." ";
$array = $this->db->fetchArray($this->db->query($sql));
if (is_array($array) == false) {
return false;
}
$this->makeArticle($array);
return true;
}
Maybe if (is_array($array) == false) is not the best way to detect if anything was returned from the database, but it looks like it is working, if anyone has a better suggestion please tell me :)
Catzwolf: Shouldn't there be some functionality to detect wether an article with articlid does exists in the system ?
p.s. Thanks for a usefull module :)