Addpixel / KirbyComments

[Kirby 2] File-based comments stored as subpages for the Kirby CMS.
MIT License
68 stars 5 forks source link

Session_start #2

Closed Ventricule closed 8 years ago

Ventricule commented 8 years ago

Hello,

I get a session_start error : Notice: A session had already been started - ignoring session_start() in [...] comments.php on line 103

I placed if (!isset($_SESSION)) { } around session_start() I have no more error message.

But, thats still not working :

I can send a first comment, the file is created, I can see it in the panel. But when I reload the page, the list is empty and $comments->isEmpty() throw 1... All params are at default value. And after the first comment, when I want to preview, the page is only reloaded, without any change or error code.

I don't know where to begin my investigation...

florianpircher commented 8 years ago

It is save to call session_start twice, from the PHP docs:

session_start() creates a session or resumes the current one based on a session identifier passed via a GET or POST request, or passed via a cookie.

So the message you are getting is just a notice and not an error.

Does the bug only occur, while you are using the if (!isset($_SESSION)) { } statement?

Ventricule commented 8 years ago

Hey, you was so fast to reply, super !

Yep, the bug also occur without statement.

I have a kirby 2.3 installation, and it happen locally and on the server.

No problems on starterkit fresh install (even no session warning)...

Will try to add plugins one by one

florianpircher commented 8 years ago

Hm, this is strange, indeed. Have you tried removing the if statement and restarting your webbrowser?

Ventricule commented 8 years ago

No problem with other plugins, and I tried in multiple browsers, but c::set('date.handler', 'strftime'); seems to be the origin of the problem !

florianpircher commented 8 years ago

Why do you think that c::set('date.handler', …) is responsible for the problem? Could you please paste the PHP messages you are getting.

Ventricule commented 8 years ago

When I set date.handler to strftime comments are no more listed, but I don't have any messages.

florianpircher commented 8 years ago

The KirbyComments plugin does use Kirby’s default date function in comments/comments.php on line 95. Currently I am not sure how date.handler works and if there are any correlations between this option and #2. I am going to have a look at this.

Ventricule commented 8 years ago

Hey, I find a solution with your help, replacing line 95 by $comment_page->date('%F %T') do the job.

florianpircher commented 8 years ago

Well, '%F %T' does the job, if the date handler is set to strftime, because strftime escapes the time-string differently. To create a universal solution, I will have to work with the timestamp directly (see working with the timestamp in the Kirby docs). Expect a new release of this plugin in the following days.

Ventricule commented 8 years ago

Yes, sure, you will find a better solution. Thank you for your help !

florianpircher commented 8 years ago

Changing line 95 to …

new DateTime(date('c', $comment_page->date()))

… should do the trick. I am going to test this and release it in the following days.