Last modified: 2013-04-22 16:14:19 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 T45810, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 43810 - PHP Warning in SpecialCentralNotice.php:156: array_diff_assoc(): Argument #1 is not an array
PHP Warning in SpecialCentralNotice.php:156: array_diff_assoc(): Argument #1 ...
Status: RESOLVED FIXED
Product: MediaWiki extensions
Classification: Unclassified
CentralNotice (Other open bugs)
unspecified
All All
: Normal minor (vote)
: ---
Assigned To: Matt Walker
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-01-10 04:55 UTC by Matt Walker
Modified: 2013-04-22 16:14 UTC (History)
5 users (show)

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


Attachments

Description Matt Walker 2013-01-10 04:55:16 UTC
PHP Warning:  array_diff_assoc(): Argument #1 is not an array in /usr/local/apache/common-local/php-1.21wmf7/extensions/CentralNotice/special/SpecialCentralNotice.php on line 156

This looks to be caused by some problem in the logging code.

I'm tracking this with FR-Tech mingle card #730 [https://mingle.corp.wikimedia.org/projects/fundraiser_2012/cards/730].
Comment 1 Dereckson 2013-01-10 13:21:54 UTC
[ Bug analysis ]

(i) $allCampaignNames is an array filled with this code:
	// Get all the initial campaign settings for logging
	$allCampaignNames = $cndb->getAllCampaignNames();
	$allInitialCampaignSettings = array();
	foreach ( $allCampaignNames as $campaignName ) {
			$settings = $cndb->getCampaignSettings( $campaignName, false );
			$allInitialCampaignSettings[ $campaignName ] = $settings;
	}

(ii) CentralNoticeDB::getCampaignSettings is documented to always return an array. This is a documentation error: it returns false if the SELECT query doesn't return result:
	(...)
	if ( $row ) {
		(...)
	} else {
		return false;
	}
	(...)

(iii) So in the array_diff_assoc(), first argument $allInitialCampaignSettings[$campaignName] could be either an array, either false.

[ Fixes suggestions]

(1) Consider to return an empty array() or to document the mixed return argument in CentralNoticeDB::getCampaignSettings
 
(2) If we're in the scenario of a new CentralNotice campaign, I guess an empty array in 1 would be the idea solution.

If it's another thing (legacy CentralNotice campaigns not in table?), add:
if ( $allInitialCampaignSettings[ $campaignName ] === false ) continue;
Comment 2 Matt Walker 2013-01-10 22:07:54 UTC
This patch should resolve the issue. https://gerrit.wikimedia.org/r/43355
Comment 3 Matt Walker 2013-01-10 22:08:45 UTC
@Dereckson -- thanks for the analysis. That sped this up considerably.
Comment 4 Dereckson 2013-01-10 22:55:34 UTC
You're welcome.
Comment 5 Alex Monk 2013-02-16 21:47:30 UTC
Merged by Pgehres on the 11th of January.

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


Navigation
Links