Skip to content

Remove array_column function#10943

Closed
rdeutz wants to merge 2 commits intojoomla:stagingfrom
rdeutz:remove_array_column
Closed

Remove array_column function#10943
rdeutz wants to merge 2 commits intojoomla:stagingfrom
rdeutz:remove_array_column

Conversation

@rdeutz
Copy link
Copy Markdown
Contributor

@rdeutz rdeutz commented Jun 27, 2016

Pull Request for Issue #10942 .

Summary of Changes

replaced a not in 5.4 available function with some pure php code that should do the same thing

Testing Instructions

see #10670

rdeutz added 2 commits June 27, 2016 15:09
removed array_column function and relace it with some php core to do the same thing

fix joomla#10942
@rdeutz rdeutz changed the title Remove array column Remove array_column function Jun 27, 2016
@ghost
Copy link
Copy Markdown

ghost commented Jun 27, 2016

There's also an API function doing the same like array_column:
ArrayHelper::getColumn($redirects, 'old_url')

@rdeutz
Copy link
Copy Markdown
Contributor Author

rdeutz commented Jun 27, 2016

@bertmert because there is a native function I would depreciate the function, if we have a higher minimum PHP version it should go away. So I think a valid argument for using it is that we can identify the places where we have to replace code. For me not a great argument :-)

@ggppdk
Copy link
Copy Markdown
Contributor

ggppdk commented Jun 27, 2016

Why are we not using an array indexed by:
$redirect['old_url']
that points to object references of $redirect

and then use isset() ? it should be much faster

@mbabker
Copy link
Copy Markdown
Contributor

mbabker commented Jun 27, 2016

It looks like ArrayHelper::getColumn() can deal with nested arrays while array_column() is a single array only. I guess that's one reason to keep it but perhaps redo the internals to just use array_column().

/off-topic

@rdeutz
Copy link
Copy Markdown
Contributor Author

rdeutz commented Jun 27, 2016

@ggppdk I don't have a good feeling to use an url as an index for an array.

@ggppdk
Copy link
Copy Markdown
Contributor

ggppdk commented Jun 27, 2016

@rdeutz

I don't have a good feeling to use an url as an index for an array.

i did not know that, i missed this,
do you have a link mentioning the dangers of it?

Understanding the PHP array implementation
the "index" , in our case url (string) will be hashed, and any collisions are handled with a linked list that holds the real "index" that was hashed

or do you mean something else ?

@rdeutz
Copy link
Copy Markdown
Contributor Author

rdeutz commented Jun 27, 2016

@ggppdk just a feeling without evidence, same level as I don't use spaces in a filename :-)

@ggppdk
Copy link
Copy Markdown
Contributor

ggppdk commented Jun 27, 2016

I see what you mean now,

any binary data can be used as index in PHP, hash function will just read bytes

In PHP, associative arrays are implemented as hashtables with some extra functions

[EDIT]
please anyone correct me here, if i am missing something

also this PR should work, (but i have not taken time to test it)

@brianteeman
Copy link
Copy Markdown
Contributor

I assume that this can be closed as @eilsonge merged #10947 ??


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/10943.

@wilsonge
Copy link
Copy Markdown
Contributor

Yes - I was in the middle of typing that :) I've gone with the polyfill as it's effectively making our code optimised and forwards compatible

@wilsonge wilsonge closed this Jun 27, 2016
@rdeutz rdeutz deleted the remove_array_column branch August 1, 2016 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants