@@ -171,8 +171,48 @@ install_wp() {
171171 fi
172172
173173 echo " Downloading extra MySQL database driver..."
174+ # Create directory if it doesn't exist
175+ mkdir -p $WP_CORE_DIR /wp-content/
176+
177+ # Try to download the db.php file with verification
174178 download https://raw.github.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR /wp-content/db.php
175179
180+ # Check if download was successful and file is not empty
181+ if [ ! -s " $WP_CORE_DIR /wp-content/db.php" ]; then
182+ echo " Warning: Downloaded db.php file is empty or download failed."
183+
184+ # Check if we have a local copy in the repository
185+ if [ -f " bin/db.php" ]; then
186+ echo " Using local fallback copy of db.php from bin/db.php"
187+ cp bin/db.php $WP_CORE_DIR /wp-content/db.php
188+ elif [ -f " ${0%/* } /db.php" ]; then
189+ # Try to find db.php in the same directory as the script
190+ echo " Using local fallback copy of db.php from script directory"
191+ cp " ${0%/* } /db.php" $WP_CORE_DIR /wp-content/db.php
192+ else
193+ # Create a simple db.php file inline as last resort
194+ echo " Creating a minimal db.php file as fallback"
195+ cat > $WP_CORE_DIR /wp-content/db.php << 'EOL '
196+ <?php
197+ /**
198+ * Fallback database driver to ensure tests can run
199+ */
200+ if ( ! defined( 'WP_USE_EXT_MYSQL' ) ) {
201+ define( 'WP_USE_EXT_MYSQL', false );
202+ }
203+ EOL
204+ fi
205+
206+ # Verify that db.php exists and is not empty
207+ if [ ! -s " $WP_CORE_DIR /wp-content/db.php" ]; then
208+ echo " Error: Failed to create a valid db.php file. Tests may not work correctly."
209+ else
210+ echo " Fallback db.php file created successfully."
211+ fi
212+ else
213+ echo " db.php downloaded successfully."
214+ fi
215+
176216 echo " WordPress core installation complete!"
177217}
178218
0 commit comments