cdaecke / md_newsfrontend

This TYPO3 extension enables feUsers to create news records in the frontend.
Other
3 stars 3 forks source link

Error while saving from frontend form #7

Closed Kamikc2709 closed 5 years ago

Kamikc2709 commented 5 years ago

So, my problem is, that I get an error while saving the news from frontend form. I'm on Typo3 8.7.13.

Typo3 log says: Argument 1 passed to Mediadreams\MdNewsfrontend\Domain\Model\News::setTxMdNewsfrontendFeuser() must be an instance of TYPO3\CMS\Extbase\Domain\Model\FrontendUser, null given, called in [...]/typo3conf/ext/md_newsfrontend/Classes/Controller/NewsController.php on line 71

cdaecke commented 5 years ago

You get this message, because you are not logged in as a frontend user.

Be sure that you are logged in!

Kamikc2709 commented 5 years ago

I am logged in all the time. If I was not logged in, I could not visit the page, the plugin is implemented and could not see the plugin because I have to be in a specific usergroup to see it.

After some investigation I can say that I have two problems with the extension. First, it does not recognize that I am logged in (do not know why) and, secondly, I have problems with the RTE. When RTE is enabled, it is not possible to insert text in the textarea. Parsley just says that the text value is required.

I have taken the following steps (with RTE disabled):

  1. Make a new entry
  2. Enter title, teaser and text
  3. Try to save, but an error has occurred

Maybe it is caused by the Typo3 version?

cdaecke commented 5 years ago

I am logged in all the time. If I was not logged in, I could not visit the page, the plugin is implemented and could not see the plugin because I have to be in a specific usergroup to see it.

Hm, that's interesting... Could you please add the following line into the New.html template in line 5 and push the Create new button on your website:

<f:debug>{user}</f:debug>

What output do you get? If you dont get any output, please place the following code in the BaseController.php at the beginning of the initializeAction() and reload the form:

\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($GLOBALS['TSFE']->fe_user->user);

What output do you get?

After some investigation I can say that I have two problems with the extension. First, it does not recognize that I am logged in (do not know why) and, secondly, I have problems with the RTE. When RTE is enabled, it is not possible to insert text in the textarea. Parsley just says that the text value is required.

Which browser on which operating system are you using? You will find a list with all supported browsers and systems here.

Kamikc2709 commented 5 years ago

What output do you get?

Interessting, I get a NULL…

The debug in BaseController shows an array with the data of the logged in User. I could copy & paste the array, if you would like to have a look on it.

Which browser on which operating system are you using?

Mac OSX with Firefox. Should be supported, but when I got the time, I will test it on different maschines.

cdaecke commented 5 years ago

Do you get any output with the following line in the initializeAction() in the BaseController.php?

\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($GLOBALS['TSFE']->fe_user->user['uid']);

If you get an ID, please add the following line in the initializeAction() in the BaseController.php on line 121. Do you get an user object?

\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($this->feuserObj);
Kamikc2709 commented 5 years ago

I get a Uid, but no userObject

Bildschirmfoto 2019-04-26 um 11 23 55 Bildschirmfoto 2019-04-26 um 11 23 38
cdaecke commented 5 years ago

But there is an user in the table fe_users with uid=1, right?

What dou you get with the following debug line?

\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($this->userRepository);
Kamikc2709 commented 5 years ago

User with id 1 is the user i use to login. Debug:

Bildschirmfoto 2019-04-26 um 12 21 39
cdaecke commented 5 years ago

Now it is getting realy interesting!

Could you please add the following code temporary in typo3/sysext/extbase/Classes/Domain/Repository/FrontendUserRepository:

public function findByUid($uid)
{
    $query = $this->createQuery();

    $queryParser = $this->objectManager->get(\TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::class);
    \TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($queryParser->convertQueryToDoctrineQueryBuilder($query)->getSQL());
}

Now you should get a query. If you run this query on the database, do you get a result? If not, can you please paste the query?

Kamikc2709 commented 5 years ago

I get 8 results inside my database with the query (after debugging which value is :dcvalue1).

SELECTfe_users.* FROMfe_users`fe_users WHERE (fe_users.tx_extbase_type = :dcValue1) AND (fe_users.pid = 268) AND ((fe_users.deleted = 0) AND (fe_users.disable = 0) AND (fe_users.starttime <= 1556286780) AND ((fe_users.endtime = 0) OR (fe_users.endtime > 1556286780)))`

cdaecke commented 5 years ago

My query looks almost the same. The (fe_users.tx_extbase_type = :dcValue1) AND part is missing. So please add the following line to the debug code in the FrontendUserRepository:

\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($queryParser->convertQueryToDoctrineQueryBuilder($query)->getParameters());

This should give you the value for :dcValue1.

So far, I guess, that another extension interferes with the frontend user repositoy. For further debugging I would disable other extensions and activate them one by one.

Kamikc2709 commented 5 years ago

Ok, I have a solution for this issue.

There was a conflict with the extension femanager. Just make sure to install this extension after installing md_newsfrontend.

Don't know exactly why, but this solved my problem.

Thank you very much for your help. :-)

The issue with the RTE is still under investigation.

cdaecke commented 5 years ago

Good to hear and thank you very much for the hint, that in some circumstances ext:femanager needs to be installed before installing ext:md_newsfrontend.

If you need further help with the RTE/validation problem do not hesitated to open a new issue.