dereuromark / cakephp-translate

A CakePHP plugin to manage translations of your static content the easy way via web backend.
MIT License
17 stars 3 forks source link

Expression `translate_project_id` is missing operator (IS, IS NOT) with `null` value. #30

Closed theChaosCoder closed 7 months ago

theChaosCoder commented 3 years ago

Fresh cake4 (v4.2.3) installation. Happens when I open http://localhost:8765/admin/translate/

My steps:

composer require dereuromark/cakephp-translate:dev-master
bin/cake plugin load Translate
bin/cake migrations migrate -p Translate

image

dereuromark commented 3 years ago

Please open PRs :)

theChaosCoder commented 3 years ago

In TranslationComponent.php Id is always null. $TranslationProjects->getDefaultProjectId() also returns null. Is this correct? (I mean I don't have any projects yet...)

The TranslateStrings->coverage() functions seems to expect an id!? $coverage = $this->TranslateDomains->TranslateStrings->coverage($this->Translation->currentProjectId());

public function currentProjectId() {
    $id = $this->getController()->getRequest()->getSession()->read('TranslateProject.id');
    if ($id === null) {
        /** @var \Translate\Model\Table\TranslateProjectsTable $TranslationProjects */
        $TranslationProjects = TableRegistry::getTableLocator()->get('Translate.TranslateProjects');
        $id = $TranslationProjects->getDefaultProjectId();

        $this->getController()->getRequest()->getSession()->write('TranslateProject.id', $id);
    }

    return $id;
}
dereuromark commented 3 years ago

No you should set up a default project first. Check if docs mention how.

All is pretty unstable still.

dereuromark commented 7 months ago

Fixed in master with https://github.com/dereuromark/cakephp-translate/commit/bacb7a9dda2ff24ac0fdd0434b50b2d765047414#diff-ca4e08e36b5baa444389547883a68cc76854d9649523eb72997b5f52fecd1f97R172-R174

You can make a backport with similar 3 line change for your branch if needed. But I would encourage helping me to get the Cake 5.x version (master branch) to work again and move on from there.