Add undeclared variables to the Feed entity class
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3239690. -->
Reported by: [andypost](https://www.drupal.org/user/118908)
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>Working on <span class="drupalorg-gitlab-issue-link project-issue-status-info project-issue-status-7"><a href="https://www.drupal.org/project/drupal/issues/3239552" title="Status: Closed (fixed)">#3239552: Improve hash() calculation for PHP 8.1</a></span> faced that the <code>source_string</code> property undeclared in entity class</p>
<h4 id="summary-steps-reproduce">Steps to reproduce</h4>
<p>See usage in <code>\Drupal\aggregator\ItemsImporter::refresh()</code></p>
<div class="codeblock">
<pre><span style="color: #000000"><span style="color: #0000BB"><?php<br></span><span style="color: #007700">...<br> </span><span style="color: #FF8000">// We store the hash of feed data in the database. When refreshing a<br> // feed we compare stored hash and new hash calculated from downloaded<br> // data. If both are equal we say that feed is not updated.<br> </span><span style="color: #0000BB">$hash </span><span style="color: #007700">= </span><span style="color: #0000BB">$success </span><span style="color: #007700">? </span><span style="color: #0000BB">hash</span><span style="color: #007700">(</span><span style="color: #DD0000">'sha256'</span><span style="color: #007700">, </span><span style="color: #0000BB">$feed</span><span style="color: #007700">-></span><span style="color: #0000BB">source_string</span><span style="color: #007700">) : </span><span style="color: #DD0000">''</span><span style="color: #007700">;<br>...<br></span><span style="color: #0000BB">?></span></span></pre></div>
<p>But in <code>\Drupal\aggregator\Plugin\aggregator\fetcher\DefaultFetcher::fetch()</code> the variable is set to <code>FALSE</code></p>
<div class="codeblock">
<pre><span style="color: #000000"><span style="color: #0000BB"><?php<br> </span><span style="color: #007700">public function </span><span style="color: #0000BB">fetch</span><span style="color: #007700">(</span><span style="color: #0000BB">FeedInterface $feed</span><span style="color: #007700">) {<br> </span><span style="color: #0000BB">$request </span><span style="color: #007700">= new </span><span style="color: #0000BB">Request</span><span style="color: #007700">(</span><span style="color: #DD0000">'GET'</span><span style="color: #007700">, </span><span style="color: #0000BB">$feed</span><span style="color: #007700">-></span><span style="color: #0000BB">getUrl</span><span style="color: #007700">());<br> </span><span style="color: #0000BB">$feed</span><span style="color: #007700">-></span><span style="color: #0000BB">source_string </span><span style="color: #007700">= </span><span style="color: #0000BB">FALSE</span><span style="color: #007700">;<br>...<br> if (</span><span style="color: #0000BB">$response</span><span style="color: #007700">-></span><span style="color: #0000BB">hasHeader</span><span style="color: #007700">(</span><span style="color: #DD0000">'Last-Modified'</span><span style="color: #007700">)) {<br> </span><span style="color: #0000BB">$feed</span><span style="color: #007700">-></span><span style="color: #0000BB">setLastModified</span><span style="color: #007700">(</span><span style="color: #0000BB">strtotime</span><span style="color: #007700">(</span><span style="color: #0000BB">$response</span><span style="color: #007700">-></span><span style="color: #0000BB">getHeaderLine</span><span style="color: #007700">(</span><span style="color: #DD0000">'Last-Modified'</span><span style="color: #007700">)));<br> }<br> </span><span style="color: #0000BB">$feed</span><span style="color: #007700">-></span><span style="color: #0000BB">http_headers </span><span style="color: #007700">= </span><span style="color: #0000BB">$response</span><span style="color: #007700">-></span><span style="color: #0000BB">getHeaders</span><span style="color: #007700">();<br></span><span style="color: #0000BB">?></span></span></pre></div>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>- Declare property as string and fix initial value.<br>
- remove usage of <code>http_headers</code> as no core/contrib usage found</p>
<h3 id="summary-remaining-tasks">Remaining tasks</h3>
<p>- consensus<br>
- review<br>
- commit</p>
<h3 id="summary-ui-changes">User interface changes</h3>
<p>no</p>
<h3 id="summary-api-changes">API changes</h3>
<p>property is declared</p>
<h3 id="summary-data-model-changes">Data model changes</h3>
<p>no</p>
<h3 id="summary-release-notes">Release notes snippet</h3>
<p>no</p>
> Related issue: [Issue #3239552](https://www.drupal.org/node/3239552)
> Related issue: [Issue #2532776](https://www.drupal.org/node/2532776)
> Related issue: [Issue #2527114](https://www.drupal.org/node/2527114)
> Related issue: [Issue #2016679](https://www.drupal.org/node/2016679)
issue