Pregunta

Por lo tanto, tengo este código:

        } else {

            $photograph_moderation = new PhotographModeration($this->photograph_id);
            $photograph_moderation->purgePhotograph();

            //eventually take to an error page
            die('image is not big enough to upload');

        }

purgePhotograph la función () es llamado correctamente cuando se cumple esta condición, pero el guión no parece que muere. ¿Hay una razón por la cual mueren no se llamará aquí? purgePhotograph () no tiene guión matar comandos tampoco.

Aquí está la función purge_photograph:

public function purgePhotograph() {

    $db = Connect::connect();
    $photograph_id = $db->real_escape_string($this->photograph_id);

    $query = "SELECT * from photographs WHERE id='{$this->photograph_id}'";
    $result = $db->query($query);
    $photograph = $result->fetch_assoc();

    if ($photograph['location'])
    unlink($photograph['location']);

    if ($photograph['thumbnail_location'])
    unlink($photograph['thumbnail_location']);

    if ($photograph['watermark_location'])
    unlink($photograph['watermark_location']);

    if ($photograph['xsmall_location'])
    unlink($photograph['xsmall_location']);

    if ($photograph['small_location'])
    unlink($photograph['small_location']);

    if ($photograph['medium_location'])
    unlink($photograph['medium_location']);

    if ($photograph['large_location'])
    unlink($photograph['large_location']);

    if ($photograph['xlarge_location'])
    unlink($photograph['xlarge_location']);

    if ($photograph['xxlarge_location'])
    unlink($photograph['xxlarge_location']);

    if ($photograph['xxxlarge_location'])
    unlink($photograph['xxxlarge_location']);

    $query = "DELETE from photographs WHERE id='{$this->photograph_id}'";
    $result = $db->query($query);

    $query = "DELETE from photograph_tags WHERE photograph_id='{$this->photograph_id}'";
    $result = $db->query($query);

}
¿Fue útil?

Solución

Tal vez ahora es el momento de instalar un php depurador módulo y entrar en el código en cuestión.
Xdebug y por ejemplo, netbeans como el trabajo frontend lo suficientemente bien.

Otros consejos

Comprobar si purgePhotograph () devuelve. Tal vez tiene un deadloop o toma mucho tiempo.

Wow, el problema era purgePhotograph () nunca tuvo un retorno 1; al final. No sabía que esto era necesario para el seguimiento de las líneas a ejecutar.

Trate de ponerlo en un bloque try / catch. Tal vez algo está lanzando una excepción antes de morir puede conseguir ejecutado.

¿Está recibiendo algún error?

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top