Page 1 of 1

echo/return in the core

Posted: Fri Jul 05, 2013 2:21 pm
by onli
Because of the smartification, it turned out that a lot of functions in the core had to be catched with ob_start and then the buffer filled into smarty-variables to position the sections in the desired flow. So I already started to change some functions to use return instead of echo.

I realize that this might be problematic, because there was a pattern before: Functions called print_X echoed their content. Now that is mixed up.

I want to change that by letting all functions return their content, always. Only the very first level, index.php/genpage.inc.php and serendipity_admin.php, should echo stuff.

Does that plan has flaws? Or do all agree?


PS: I feel like I already wrote that in this forum, but I can't find it. Maybe I just wanted to do that.

Re: echo/return in the core

Posted: Fri Jul 05, 2013 4:41 pm
by garvinhicking
Hi!

Sounds doable, and is definitely better in terms of API design. This is an API BC break, so we should create a list of all functions that no longer echo stuff, so that plugin developers can adapt their code by searching if they use that function/method.

Best regards,
Garvin

Re: echo/return in the core

Posted: Fri Jul 05, 2013 4:45 pm
by onli
Agreed, I already startet that documentation in https://github.com/s9y/Serendipity/blob ... 0-temp#L19.