Followup to #3039026: Deprecate file_directory_temp() and move to FileSystem service
Problem/Motivation
The following comment in \Drupal\Core\Database\Driver\sqlite\Install\Tasks::connect refers to a removed function, file_directory_temp()
// We cannot use file_directory_temp() here because we haven't yet
// successfully connected to the database.file_directory_temp() is deprecated and moved to the FileSystem service. See change notice.
Proposed resolution
Replace mention of the deprecated function in the comment with the new function.
\Drupal::service('file_system')->getTempDirectory() also requires database access.
Remaining tasks
Make a patch
Review
Commit
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | 3157370-14.patch | 975 bytes | tvb |
| #14 | interdiff--11-14.txt | 838 bytes | tvb |
| #11 | 3157370-11.patch | 872 bytes | s_bhandari |
Comments
Comment #2
s_bhandari commentedComment #3
s_bhandari commentedAdded a patch for the same.
Comment #4
s_bhandari commentedComment #5
nitvirus commentedI think we should replace the function file_directory_temp() (as this is deprecated) with
\Drupal::service('file_system')->getTempDirectory();. So, instead of removing the comment fully we should just replace the deprecated function with the code.Thanks.
Comment #6
s_bhandari commentedComment #7
s_bhandari commentedHi @nitvirus,
Thanks for reviewing the issue. The original requirement here was to remove the comment referring to file_directory_temp() and that has been done in this patch. Also, I think the point that you are depicting here has already been addressed. Please do have a check and let me know if there are any other thoughts on this.
Thanks.
Comment #8
nitvirus commentedSure,
Correct @S_Bhandari, the scope defines we should remove the comment.
The patch looks fine , can we also remove the empty line coming on top of comments.
Comment #9
s_bhandari commentedSure, I will work on this.
Thanks.
Comment #10
mradcliffeI think this still could be a novice issue because it needs an issue summary update to figure out why the comment exists.
I think the comment may have some important history. Can you update the issue summary after researching why/when the comment got into the code base in the first place? This could be going into drupal 7's old directory structure for database drivers.
Comment #11
s_bhandari commentedHi @nitvirus,
Added a patch for the observation you have shared. Please review the same and let me know for any other observation on this.
Thanks.
Comment #12
s_bhandari commentedHi @mradcliffe,
I did research on when the comment got into the code base in the first place by running the git blame on the file and I can see that it is added in the commit ID - a5a2ce92, on 2012-11-20 10:57:13. I also have looked into the commit ID by running git show [COMMIT_ID] and can confirm that it was added in this commit only. Please do let me know if this information is fine with you.
Thanks.
Comment #13
mradcliffeThat's a good start. Finding the commit allows us to find that it was added in #203955: Create database at installation time. A really old issue. Back then, issues sometimes got multiple commits, spanned multiple versions. The patch that ended up being committed, that's relevant is https://www.drupal.org/project/drupal/issues/203955#comment-6698374.
We need to dig into that issue to starting from that comment, going up, and see if there was any discussion or reason why it was added. It wasn't in the initial several patches in the issue that I found.
We're looking for the explanation to determine if that comment should be removed in this patch or not.
Comment #14
tvb commentedThe comment appears for the first time in the patch file in comment #36.
file_directory_temp() is deprecated and moved to the FileSystem service. See change notice.
\Drupal::service('file_system')->getTempDirectory() also requires database access.
Tested by setting a faulty database connection and then executing a
drush php-eval "var_dump(\Drupal::service('file_system')->getTempDirectory());"command.
The attached patch changes the comment to:
// We cannot use \Drupal::service('file_system')->getTempDirectory()
// here because we haven't yet successfully connected to the database.
Issue summary updated accordingly.
Comment #16
awset commentedThe patch file on #14 is working. Tested on 9.2 branch.
Comment #17
awset commentedComment #20
catchCommitted/pushed to 9.2.x and cherry-picked to 9.1.x, thanks!