Flourish PHP Unframework
This is an archived copy of the forum for reference purposes

@ to fActiveRecord→sortByCallback()

posted by audvare 8 years ago

Perhaps add an @ to fActiveRecord->sortByCallback():

	public function sortByCallback($callback)
		@usort($this->records, $callback);

Reason: If you call a related records method like buildOtherClassNames() this modifies the array (because it adds to the object in the array) and will result in a warning if you have warnings on. I think in this case it is acceptable to ignore this warning. If a site is not using output buffering at all, then printing will occur usually at position 0 of the HTML output. This means it's no longer valid and JavaScript might fail to execute properly.

Also, your forum allows blank subjects.

Yeah, I've noticed that warning before. I think I had to make sure I created all of the related objects before I started the sort, but I remember that being a pain and not very intuitive for future maintainers.

I like the idea of being able to suppress the warning, however I would prefer to do it using fCore::startErrorCapture() since the @ symbol suppresses all errors and can be disabled by some extensions. Also, I am thinking the warning should normally be triggered, but if TRUE is passed as a second parameter (maybe $quiet?), then the warnings would be suppressed.

posted by wbond 8 years ago