q2a / question2answer

Question2Answer is a free and open source platform for Q&A sites, running on PHP/MySQL.
http://www.question2answer.org/
GNU General Public License v3.0
1.64k stars 629 forks source link

Private functions of qa-filter-basic.php #182

Closed sama55 closed 9 years ago

sama55 commented 9 years ago

Scope of validate_length() and validate_post_email() of qa-filter-basic.php were changed from "public" to "private" in V1.7. Plugin Compatibility was lost in this change. Return to public method.

Before (now): private function validate_length( ... private function validate_post_email( ...

After: public function validate_length( ... public function validate_post_email( ...

svivian commented 9 years ago

What plugin is using those functions?

The methods are specific to the basic filter plugin so should not be accessed from outside code. Note that it does say above those functions, "The definitions below are not part of a standard filter module, but just used within this one".

sama55 commented 9 years ago

http://www.question2answer.org/qa/23346/update-plugin-extra-question-field-v1-6-4

svivian commented 9 years ago

Had a think about this and decided not to change the function visibility. Those functions shouldn't be used from outside the plugin, and it was only due to PHP4 support that they happened to be public.

I checked your plugin and you only call the function in one place so you can update your code easily to work around this. Either copy-paste the validate_length function to that class and call it, or do a simple length check right there without calling a separate function.

Hope that helps.

svivian commented 9 years ago

I've decided on a compromise for this issue (ffdadf7). The functions (and others that had been marked private) have been changed to be public, but are now marked as deprecated, meaning they will be reverted to private again in the future. This will give all plugin developers and core hackers some more time to change their code not to rely on these functions.

sama55 commented 9 years ago

Thanks Scott.