From 98ec2fbd729aa55ab7aa4fdee01c932b7dfefc42 Mon Sep 17 00:00:00 2001 From: ShilpaG <129755123+ShilpaG813@users.noreply.github.com> Date: Sat, 22 Nov 2025 18:30:36 +0530 Subject: [PATCH] Add fallback for missing PHP 8.4 DOM class pages PHP 8.4 introduced namespaced DOM classes such as Dom\Node, Dom\Element, Dom\Document, etc. These pages exist on php.net but are not included in the php.net/download-docs.php archive that DevDocs uses. This fallback downloads these missing class pages directly from php.net when they are not present locally. --- lib/docs/scrapers/php.rb | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/lib/docs/scrapers/php.rb b/lib/docs/scrapers/php.rb index 5a2f42e24c..aa8045bfe2 100644 --- a/lib/docs/scrapers/php.rb +++ b/lib/docs/scrapers/php.rb @@ -71,5 +71,37 @@ def get_latest_version(opts) doc.at_css('table > tbody > .stable:last-of-type > td > a').content.strip end +# ------------------------------------------------------------------------------ +# Fallback: PHP 8.4 DOM namespaced classes are NOT included in the downloadable +# documentation archive, so we fetch them manually from php.net if missing. +# ------------------------------------------------------------------------------ + +def download_missing_dom_classes + missing_dom_classes = %w( + class.dom-node.html + class.dom-element.html + class.dom-document.html + class.dom-htmldocument.html + class.dom-xmldocument.html + class.dom-text.html + class.dom-nodelist.html + class.dom-tokenlist.html + ) + + missing_dom_classes.each do |page| + next if path_exists?(page) + + puts "Fetching missing PHP 8.4 DOM page: #{page}" + download(page) + end +end + +# Call fallback after normal downloads +def scrape + super + download_missing_dom_classes +end + + end end