Last modified: 2013-10-23 18:17:35 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T35691, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 33691 - PHP Warning on showing Release Notes due to the fact that file does not exist
PHP Warning on showing Release Notes due to the fact that file does not exist
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
Installer (Other open bugs)
1.18.x
All All
: Normal minor (vote)
: 1.19.0 release
Assigned To: Nobody - You can work on this!
: easy, patch, patch-need-review
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-01-12 22:41 UTC by moejoe0000
Modified: 2013-10-23 18:17 UTC (History)
4 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
Patch as outlined in commets #2, #3 (1.64 KB, patch)
2012-02-08 10:21 UTC, moejoe0000
Details

Description moejoe0000 2012-01-12 22:41:17 UTC
Use MediaWiki 1.18.1 and try to look at Release Notes in Installer:

http://127.0.0.1/w/mw-config/index.php?page=ReleaseNotes

Get the following warning:

Warning: file_get_contents([...]/www/w/includes/installer/../../RELEASE-NOTES): failed to open stream: No such file or directory in [...]/www/w/includes/installer/WebInstallerPage.php on line 1236.

The file "RELEASE-NOTES" does not exist (anymore) but it was renamed to "RELEASE-NOTES-1.18". WebInstallerPage.php does neither know this renaming nor check on existence of file.
Comment 1 Sam Reed (reedy) 2012-01-13 17:09:46 UTC
I think we just need to get from $wgVersion the major and minor version, so we can drop the last number, and append that to the link to the release notes file

Ideally this needs fixing before 1.19 tarball


Attempting to symlink is just going to be asking for trouble
Comment 2 moejoe0000 2012-01-14 10:01:33 UTC
For me the following modification of /includes/installer/WebInstallerPage.php works well:

--- trunk/phase3/includes/installer/WebInstallerPage.php (revision 108689)
+++ trunk/phase3/includes/installer/WebInstallerPage.php (working copy)
@@ 1245,3 1245,11 @@
 class WebInstaller_UpgradeDoc extends WebInstaller_Document {
-	protected function getFileName() { return 'RELEASE-NOTES'; }
+	protected function getFileName() {
+		global $wgVersion;
+
+		if(! preg_match( '/^(\d+)\.(\d+).*/i', $wgVersion, $result ) ) {
+			throw new MWException('Variable $wgVersion has an invalid value.');
+		}
+
+		return 'RELEASE-NOTES-' . $result[1] . '.' . $result[2]; 
+	}
 }

Moreover, for me it seems rasonable to check if the user has deleted (or renamed...) one of the files:

--- trunk/phase3/includes/installer/WebInstallerPage.php (revision 108689)
+++ trunk/phase3/includes/installer/WebInstallerPage.php (working copy)
@@ 1235,3 1235,7 @@
 	public function getFileContents() {
-		return file_get_contents( dirname( __FILE__ ) . '/../../' . $this->getFileName() );
+		$file = dirname( __FILE__ ) . '/../../' . $this->getFileName();
+		if( ! file_exists( $file ) ) {
+			return wfMsgNoTrans( 'config-nofile', $file );
+		}
+		return file_get_contents( $file );
	}
--- trunk/phase3/includes/installer/Installer.i18n.php (revision 108689)
+++ trunk/phase3/includes/installer/Installer.i18n.php (working copy)
Comment 3 moejoe0000 2012-01-14 10:03:33 UTC
Sorry, I missed a bit:

--- trunk/phase3/includes/installer/Installer.i18n.php (revision 108689)
+++ trunk/phase3/includes/installer/Installer.i18n.php (working copy)
@@ 559,2 559,3 @@
 * [https://lists.wikimedia.org/mailman/listinfo/mediawiki-announce MediaWiki release mailing list]",
+	'config-nofile'     => 'File "$1" could not be found.',
 );
Comment 4 Sumana Harihareswara 2012-02-07 01:49:17 UTC
moejoe0000, thanks for the patch!  Could you please provide the patch as a unified diff against trunk?

https://en.wikipedia.org/wiki/en:Diff#Unified_format

Short version: $ svn di > /Users/you/Desktop/my_first_patch.diff

In case you need help with that: http://openhatch.org/missions/diffpatch

Thanks!
Comment 5 moejoe0000 2012-02-08 10:21:16 UTC
Created attachment 9969 [details]
Patch as outlined in commets #2, #3
Comment 6 Mark A. Hershberger 2012-02-10 20:40:45 UTC
r111198

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links