Jdlrobson has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/376782 )
Change subject: Avoid undefined notices when obtaining collection ...................................................................... Avoid undefined notices when obtaining collection Instead of using$_SESSION['wsCollection'] rely on the method CollectionSession::getCollection() which will return an empty collection when a session is not present. This empty collection unlike before is prepopulated with the fields required to render a section. This avoids notices. Bug: T175063 Change-Id: Ieda48f5b83ec76ec5cfe62f48f2397ac1710c0e7 --- M Collection.php M Collection.session.php 2 files changed, 7 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Collection refs/changes/82/376782/1 diff --git a/Collection.php b/Collection.php index 9f95178..5ae49b9 100644 --- a/Collection.php +++ b/Collection.php @@ -353,7 +353,7 @@ $wgAjaxExportList[] = 'wfAjaxCollectionGetBookCreatorBoxContent'; function wfAjaxCollectionGetItemList() { - $collection = $_SESSION['wsCollection']; + $collection = CollectionSession::getCollection(); $template = new CollectionListTemplate(); $template->set( 'collection', $collection ); diff --git a/Collection.session.php b/Collection.session.php index a4d23d8..f536db7 100644 --- a/Collection.session.php +++ b/Collection.session.php @@ -22,7 +22,11 @@ */ class CollectionSession { - + const EMPTY_COLLECTION = [ + 'name' => '', + 'description' => '', + 'items' => [] + ]; /** * @return bool */ @@ -172,7 +176,7 @@ * @return array */ public static function getCollection() { - return self::purge() ? $_SESSION['wsCollection'] : []; + return self::purge() ? $_SESSION['wsCollection'] : CollectionSession::EMPTY_COLLECTION; } /** -- To view, visit https://gerrit.wikimedia.org/r/376782 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ieda48f5b83ec76ec5cfe62f48f2397ac1710c0e7 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Collection Gerrit-Branch: master Gerrit-Owner: Jdlrobson <jrob...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits