-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Warning] Array to string conversion #344
Comments
It pains me to come back to this with my head low, however this is not actually a bug at all, more like an undocumented (and only partially working) Silverstripe feature. Although using arrays for The best I can say is, |
Currently if on php 8.1 and the latest version of SS - Line 370 in /app/vendor/symbiote/silverstripe-gridfieldextensions/src/GridFieldOrderableRows.php throws an error as the sort is expected to be a string. Setting to a default convention which will work. See - symbiote/silverstripe-gridfieldextensions#344 for more details
I think this is valid & should be reopened. Although the DocBlock on DataObject might state that the parameter should be a string, it is a case of classic poorly updated documentation and obtuse APIs. For instance, the DocBlock on the private static variable states it should be a string, then immediately instantiates it to DataQuery::sort is the main place this is used, but the DocBlock there states it expects fully escaped raw SQL as the parameter (likely from purely historic reasons). It then delegates though SQLSelect::setOrderBy to SQLSelect::addOrderBy - both of which state explicitly they accept quite an accepting set of parameters and has an allowance for the direction. * @example $sql->addOrderBy("Column");
* @example $sql->addOrderBy("Column DESC");
* @example $sql->addOrderBy("Column DESC, ColumnTwo ASC");
* @example $sql->addOrderBy("Column", "DESC");
* @example $sql->addOrderBy(["Column" => "ASC", "ColumnTwo" => "DESC"]); Then contradicting years of this type of use, DataObjectSchema goes on to only accept strings... but only since Classic Silverstripe contradictory support due to poorly or undefined APIs - perhaps due to overusing config, which is a large free-form key-value database (a bit like using excel instead of a database). I argue the solution is to make the API better defined, and more in line with other common and already supported use cases. While this probably isn't the correct repository for the above argument, but I think it is highly expected this module should make allowance for arrays as the |
PHP produces a warning in relation to PR #325 when
default_sort
is an array, eg:$sortterm .= ($sortterm ? ', ' : '') . $defaultSort;
incorrectly assumes$default_sort
is always a string ~ it can be either a string or an array.CC @davejtoews
The text was updated successfully, but these errors were encountered: