[eluser]section31[/eluser]
I tried ci's image_lib for the first time and I noticed even after the initialize method returns false, some methods still return true.
Test Case:
initialize fails due to invalid path or something similar, so the properties aren't set which are required for most of the methods.
running the image_process_gd('crop') method runs and returns true here
Code:
// If the target width/height match the source then it's pointless to crop, right?
if ($this->width >= $this->orig_width AND $this->height >= $this->orig_height)
{
// We'll return true so the user thinks the process succeeded.
// It'll be our little secret...
return TRUE;
}
Why: The reason it returns true is because the used properties are defaulted to '' and when evaluated like this, they are converted to integers which is 0 making it.
Code:
// If the target width/height match the source then it's pointless to crop, right?
if (0 >= 0 AND 0 >= 0)
{
I sure hope it's not assumed that we are responsible to check for errors after every initialization before we run any methods. Also, shouldn't the error_msg property be cleared and set to array() after every start of initialization in case you want to run several methods on different images and keep the errors separate.
I haven't put much thought of a fix for this, but wouldn't simply checking if the error_msg array is empty inside each of 4 processing functions suffice.