[aur-dev] [PATCH] tu_details.php: Avoid division by zero

Florian Pritz bluewind at xinu.at
Mon Aug 26 11:59:59 EDT 2013


On 26.08.2013 17:56, Lukas Fleischer wrote:
> Do not divide by zero if the number of active TUs is unknown.
> 
> Signed-off-by: Lukas Fleischer <archlinux at cryptocrack.de>
> ---
>  web/template/tu_details.php | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/web/template/tu_details.php b/web/template/tu_details.php
> index c09e30c..667956b 100644
> --- a/web/template/tu_details.php
> +++ b/web/template/tu_details.php
> @@ -6,7 +6,9 @@ $active_tus = $row["ActiveTUs"];
>  $quorum = $row["Quorum"];
>  
>  $total = $yes + $no + $abstain;
> -$participation = $total / $active_tus;
> +if ($active_tus > 0) {
> +	$participation = $total / $active_tus;
> +}

You should probably set a default value of 0.

I don't see those patches on projects.al.org (master branch) yet so I'm
not sure if a default might be set earlier.

>  
>  if ($yes > $active_tus / 2) {
>  	$vote_accepted = true;
> 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://mailman.archlinux.org/pipermail/aur-dev/attachments/20130826/5520d5e6/attachment.asc>


More information about the aur-dev mailing list