fix: Article publish date is always replaced by current timestamp #283
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #281
Explanation:
In b77f22d#diff-62c740cd7ba615b9771602fedd2cab6bc50ac4052c3f8432913f59dbaf3d5effR48 an attempted migration away from the deprecated DBAL
fetch()
method failed.Instead of the drop-in replacement
fetchAssociative
, the wrong methodfetchOne
was chosen.Maybe the author @benjaminkott had intended to use
fetchOne
, but select the desired field rather than the entire row. (The latter approach is taken by this PR.)In
v12.0.0
(or at any time after b77f22d), the database loaded and transmitted the entire row, but only the first column of the first row was returned. (SeeDoctrine\DBAL\ForwardCompatibility\Result::fetchOne
, which callsfetchNumeric
internally.)Note that loading and transmitting the entire database row (
SELECT *
) is wasteful and slow.Therefore, instead of fixing the issue by using
fetchAssociative
, this PR fixes the issue by keepingfetchOne
but selecting only the used field ('publish_date'
).If no row is found,
fetchOne
will returnfalse
. A strictly typed check forfalse
is performed before comparing (again, strictly) to0
, in which case the current time will be used.