Review main Merged

3922[FEATURE] Multiple stdWrap executed in numeric order

Stefan Neufeind CR +2 V +2 Easy +19 −2 updated 06/03/13, 20:49

Commit message

Add possibility to use multiple stdWrap-calls in numeric order.
Offers easier usage than the existing stdWrap-chaining across
multiple hierarchy-levels.

 10 = TEXT
 10.value = a
 10.orderedStdWrap {
 	30.wrap = |.
 	10.wrap = is | working
 	10.innerWrap =  | 
 	20.wrap = This|solution
 	20.stdWrap.wrap =  | 
 }

Results in: "This is a working solution."

Review

  • Code review CR +2
    • Tolleiv Nietsch +2
    • Jo Hasenau +1
    • Sebastian Fischer +1
  • Verified V +2
    • Tolleiv Nietsch +2
    • Jo Hasenau +1

Issues 1

Files 1

Review log 20

  1. Stefan Neufeind commented on patch set 1 02/08/12, 22:14

    Unittest included. Please review this in the context of https://review.typo3.org/3855 (stdWrap for search/replace) since with this functionality here for numeric ordering we would have a generic solution that can be used with all stdWrap-functions and we could remove the special functionality for multiple replacements with a numeric index in the (soon to be merged!) search/replace-implementation. See forge-entry for #28601 for details what this means the stdWrap-replacement.
  2. Stefan Neufeind commented on patch set 1 02/08/12, 22:14

    Jo, I think you are wrong. Imho it won't collide with the split-functionality, since this implementation only works on numeric keys directly on the first hierarchy of stdWrap (where you'd add "split." or the like; everything listed in the $stdWrapOrder-array). Split works one level further down in the array. And so it also does not iterate through the full tree but just through the first level. From personal experience I'd say that level has maybe 10 items or so but not more and usually less. If you are worried about "looping through all the items" (on the first level only!) we could easily narrow down the number of items to traverse: for $stdWrapOrder the code uses: $sortedConf = array_intersect_key($this->stdWrapOrder, $conf); so we could use array_diff_key(...) here and only work on the items not already taken care of by the stdWrapOrder-listed functions. But I doubt that will be any bit noticable faster (maybe even slower). And a simple ksort()-approach wouldn't work since you would then get 1./10./2. and not the 1./2./10.-order a person would expect. We're dealing with strings here. (Maybe natsort could be used for that - but I'd bet the numberic approach used here is roughly equally fast). A separate "multiStdWrap" would imho complicate this again and is another level of hierarchy we (imho) don't need. This suggestion is just about the first hierarchy-level below stdWrap - and I don't foresee for which other cases we'll have need for numeric keys below that. To me this is the most "natural" way to handle such ordered stdWrap-calls and it works backward-compatible with the existing stdWrap-functionality.
  3. Philipp Gampe commented on patch set 1 02/08/12, 22:14

    +1 for orderedStdWrap
  4. Tolleiv Nietsch commented on patch set 2 02/08/12, 22:14

    Verified; Looks good to me, but someone else must approve Nice
  5. Stefan Neufeind commented on patch set 2 02/08/12, 22:14

    Verified; Looks good to me, but someone else must approve Would be great to get this in ...
  6. Philipp Gampe uploaded patch set 2 02/08/12, 22:14

  7. Philipp Gampe commented on patch set 2 02/08/12, 22:14

    This is a proof of concept. I did put it in front of outerWrap.
  8. Tolleiv Nietsch commented on patch set 3 V 0 02/08/12, 22:14

    by team member; Looks good to me, approved
  9. Sebastian Fischer commented on patch set 3 02/08/12, 22:14

    Looks good to me, but someone else must approve
  10. Philipp Gampe commented on patch set 3 02/08/12, 22:14

    @Jo i fixed your first comment, but I do not understand what you want for the second one. So each subkey is handled like a text object with the value of content. So each subkey has full stdWrap support and you can of course add all stdWrap functions. So what you do expect me to do here?
  11. Philipp Gampe uploaded patch set 3 02/08/12, 22:14

  12. Philipp Gampe commented on patch set 3 02/08/12, 22:14

    Documentation is done in #33715
  13. Jo Hasenau commented on patch set 1 02/08/12, 22:14

    We just can't add it the way you want to, because there is no "first level" of stdWrap - at least there shouldn't be since we introduced "chained stdWrap" functions with 4.5.x We can do things like: prioriCalc = 1 prioriCalc.field = docalculation prioriCalc.field.override.data = GP:whatever This means: Having numeric keys on the "first level" of stdWrap must implement them on any other level as well, since anything else would be inconsistent. So with your approach you would have stuff like: prioriCalc { 10 { field = test } 20 { whatever } } This would collide with any stdWrap function that is using numeric keys already, which is why I think, that introducing "multipleStdWraü" or better "orderedStdWrap" would be a much cleaner and less confusing approach. And another advantage is that it would make ordered stdWrap functions possible on ANY level.
  14. Jo Hasenau commented on patch set 1 02/08/12, 22:14

    I would prefer that you didn't submit this This will collide with stdWrap.split, which is using numeric keys as well and it will slow down the rendering process significantly, since it will test/convert each available array key multiple times. Even though I like the "sortable functions" approach, the current implementation is suboptimal. IMHO it would be better to introduce a new key for it, so that we can clearly separate it from the rest of the stdWrap functionality. Somehting like: 10 = TEXT 10.value = blah 10.multipleStdWrap { 10 { prioriCalc = 1 } 20 { dataWrap = whatever } } This way we can make sure it doesn't collide with other functions like split, and we don't have to care about the key being numeric, since we can just sort by key. This "multipleStdWrap" function should be excluded from those functions being stdWrap aware themselves though.
  15. Jo Hasenau commented on patch set 2 02/08/12, 22:14

    Verified; I would prefer that you didn't submit this Despite the fact that the submitted code works as expecte, there are still some inconsistencies and missing things: 1. orderedStdWrap should not be a "boolean", since this would mean, that you would have to explicitely activate it, which is not the case with the original stdWrap property, which is of the type "stdWrap" 2. it is still possible to add more than one stdWrap function to the numeric keys, since they are of the type "array" (which is quite cool by the way) but the PHP code for orderedStdWrap will treat them as if there was just one function possible. So +1 for the feature but -1 for the current solution.
  16. Jo Hasenau commented on patch set 3 02/08/12, 22:14

    Verified; Looks good to me, but someone else must approve I was wrong with point two of my complaints - the method already is aware of multiple stdWrap functions per numeric key. And since the type is now set correctly => thumbs up!
  17. Mr. Jenkins commented on patch set 1 02/08/12, 22:14

  18. Mr. Jenkins commented on patch set 2 02/08/12, 22:14

  19. Mr. Jenkins commented on patch set 3 02/08/12, 22:14

  20. Tolleiv Nietsch merged patch set 3 02/08/12, 22:14