medialab / ANTA

Actor Network Text Analyser
Other
56 stars 22 forks source link

EntitiesMapper.php seems to reference non-existing tables? #17

Open dentoir opened 10 years ago

dentoir commented 10 years ago

When enabling or resetting user routines, the backend chokes on the clearEntities() function in EntitiesMapper.php. The tables referenced there: anta_userxxx_documents_entities, anta_userxxx_entities_occurrences and anta_userxxx_entities do not exist for my user. I do not see where they should have been created.

bornakke commented 10 years ago

Hi Dentoir,

I had same problem. I got around it with a ugly hack (see below). I also changed the ClearAction() in the routineController.php file. I haven't committed it yet since it is only an Hack, but feel free to use it.

Best Tobias Bornakke Copenhagen University

public function clearAction(){
    Application_Model_EntitiesMapper::clearEntities( $this->_user );
    Application_Model_DocumentsMapper::clearDocuments( $this->_user );
    RoutineController::killAction();

    echo "Analysis has been reset. You are now redirected back to the admin page.";
    header( "refresh:2;url=/anta_dev/admin" ); 
}

public static function clearEntities( Application_Model_User $antaUser ){

    $stmt = Anta_Core::mysqli()->query( "SET FOREIGN_KEY_CHECKS = 0;");

    $stmt = Anta_Core::mysqli()->query( "
        TRUNCATE TABLE  anta_".$antaUser->username.".`rws_entities`
    ");

    $stmt = Anta_Core::mysqli()->query( "
        TRUNCATE TABLE  anta_".$antaUser->username.".`rws_entities_documents`
    ");

    $stmt = Anta_Core::mysqli()->query( "
        TRUNCATE TABLE  anta_".$antaUser->username.".`rws_entities_documents_saved`
    ");

    $stmt = Anta_Core::mysqli()->query( "
        TRUNCATE TABLE  anta_".$antaUser->username.".`rws_entities_tags`
    ");

    $stmt = Anta_Core::mysqli()->query( "
        TRUNCATE TABLE  anta_".$antaUser->username.".`sentences`
    ");

    $stmt = Anta_Core::mysqli()->query( "
        TRUNCATE TABLE  anta_".$antaUser->username.".`tags`
    ");

    //Lock table again
    $stmt = Anta_Core::mysqli()->query( "SET FOREIGN_KEY_CHECKS = 1;");

    return $stmt->rowCount();
}
dentoir commented 10 years ago

Your hack did fix the problem for me.