1
disky
WFSection bug in wfsarticle.php file
  • 2004/1/12 21:31

  • disky

  • Just popping in

  • Posts: 90

  • Since: 2003/10/31


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 :)

Login

Who's Online

380 user(s) are online (275 user(s) are browsing Support Forums)


Members: 0


Guests: 380


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits